<?php
/****文件说明:
@确认订单有选择门店(自提)，发票，留言，必填信息，购物币，优惠券，会员卡折扣，送货时间，自定义区域
@使用session：立即购买或者购物车数据，送货时间，自定义区域
@使用本地存储：选择门店(自提)，发票，留言，必填信息，购物币，优惠券，会员卡折扣
@使用过session的数据要在保存订单清除session
@使用过本地存储的数据，要在确认订单，购物车，产品详情js清除（order_from.js,order_cart.js,product_detail.js）
f
*****/
header("Content-type: text/html; charset=utf-8");
// header("Cache-control: private, must-revalidate");
session_cache_limiter( "private, must-revalidate" );
require_once('../config.php');
require_once('../customer_id_decrypt.php'); //导入文件,获取customer_id_en[加密的customer_id]以及customer_id[已解密]
$link = mysql_connect(DB_HOST,DB_USER,DB_PWD);
mysql_select_db(DB_NAME) or die('order_Form Could not select database');
_mysql_query("SET NAMES UTF8");
//头文件  调试请关闭此文件----start
require_once('../common/common_from.php');
require_once('select_skin.php');
require_once('../../mshop/web/model/integral.php');
$model_integral = new model_integral();
//头文件  调试请关闭此文件----end
/*测试数据*/
/* $customer_id = 3243 ;
$user_id = 194515; */
/*测试数据*/

require_once('../common/utility_fun.php');
require_once('../common/utility.php');
require_once('../common/utility_shop.php');
require_once('../proxy_info.php');

//----确认订单获取产品信息方法
require_once('order_newform_function.php');
require_once('../public_method/show_pay_way.php');

require_once('../function_model/collageActivities.php');
$collageActivities = new collageActivities($customer_id);
//----确认订单获取产品信息方法

if($_POST['op'] && $_POST['op']="check_delivery")
{
	$pid = $_POST['pid'];
	if(count($pid)> 1)
	{
		$pid = implode($pid, ',');
	}
	$is_pass = "select id from pay_on_delivery_products_t where isvalid=1 and pid in ($pid)";
	$res2    = _mysql_query($is_pass) or die('Query failed: ' . mysql_error());
	while ($row  = mysql_fetch_object($res2))
    {
        $ispay_on = $row->id;
    }
	if($ispay_on == false)
	{
		die(json_encode(array("status"=>"error",'msg'=>'该产品不支持货到付款')));
	}
	die(json_encode(array("status"=>"ok",'msg'=>'该产品支持货到付款')));
}

//----假如没有post数据和session数据，则跳转到购物车 调试请屏蔽 start

if($_POST['pid'] == '' && $_POST['pro_arr'] =='' && $_SESSION['bug_post_data_'.$user_id]==''){
	echo "<script>location.href='order_cart.php?customer_id=".$customer_id_en."';</script>";
	return ;

}
//----假如没有post数据和session数据，则跳转到购物车 调试请屏蔽 end

/* 微信端下单，fromuser为空则不能下单 start */
if( $from_type == 1 && $fromuser == '' ){
	echo "	<script>
				alert('未知错误！没有获取到个人信息！');
				location.href='order_cart.php?customer_id=".$customer_id_en."';
			</script>";
	return ;
}
/* 微信端下单，fromuser为空则不能下单 end */

$_SESSION['a_type_'.$user_id] = '';		//清空选择地址页面的session

//收货地址ID--start
//+ 韦 14:35 2016/9/3
if(empty($_SESSION['aid_'.$user_id])){
    $_SESSION['aid_'.$user_id] = '';
}
//+ 韦
$aid = -1;
$is_change_address = -1;//是否修改收货地址
if(!empty($_GET["aid"])){
  $aid = $configutil->splash_new($_GET["aid"]);      //产品ID
  $_SESSION['aid_'.$user_id] = $aid;			//存入session，方便下次跳转获取数据
  $is_change_address = 1;
}else{
	$aid = $_SESSION['aid_'.$user_id];
}
//收货地址ID--end

//单个产品--start
$pid = 0;
if(!empty($_POST["pid"])){
  $pid = $configutil->splash_new($_POST["pid"]);      			//产品ID
  $_SESSION['pid_'.$customer_id] = $pid;						//防止跳转页面丢失数据
}
if(!empty($_GET["pid"])){
  $pid = $configutil->splash_new($_GET["pid"]);      			//产品ID
   $_SESSION['pid_'.$customer_id] = $pid;						//防止跳转页面丢失数据
}
if(empty($pid)){
	$pid = $_SESSION['pid_'.$customer_id];
}
$prvalues = '';
if(!empty($_POST["sel_pros"])){
  $prvalues = $configutil->splash_new($_POST["sel_pros"]);      //所选的属性ID
}
$rcount = 0;
if(!empty($_POST["rcount"])){
  $rcount = $configutil->splash_new($_POST["rcount"]);     		//数量
}
$supply_id = -1;
if(!empty($_POST["supply_id"])){
  $supply_id = $configutil->splash_new($_POST["supply_id"]);    //供应商ID
}

//获取订货系统门店id
$o_shop_id=-1;
$o_branch_id = -1;
// $_POST['o_shop_id'] = 2;
if ( !empty($_POST['o_shop_id']) && $_POST['o_shop_id'] > 0 )
{
	$o_shop_id = $configutil->splash_new($_POST['o_shop_id']);
    $_SESSION['o_shop_id_'.$user_id] = $o_shop_id;
} else if (!empty($_SESSION['o_shop_id_'.$user_id]))
{
    $o_shop_id = $_SESSION['o_shop_id_'.$user_id];
}
//echo "  : ".$o_shop_id."<br/>";
/*
$live_room_id=0;//商城直播那边传过来的房间id
if(!empty($_POST['live_room_id'])&&is_numeric($_POST['live_room_id'])&&$_POST['live_room_id']>0){
	$live_room_id = $configutil->splash_new($_POST["live_room_id"])?$configutil->splash_new($_POST["live_room_id"]):0;
}
*/
$topic_id=0;//商城直播那边传过来的话题id
if(!empty($_POST['topic_id'])&&is_numeric($_POST['topic_id'])&&$_POST['topic_id']>0){
	$topic_id = $configutil->splash_new($_POST["topic_id"])?$configutil->splash_new($_POST["topic_id"]):0;
}
$resource_id=0;//商城直播那边传过来的资源id
if(!empty($_POST['resource_id'])&&is_numeric($_POST['resource_id'])&&$_POST['resource_id']>0){
	$resource_id = $configutil->splash_new($_POST["resource_id"])?$configutil->splash_new($_POST["resource_id"]):0;
}
$is_collage_product_info = '';	//是否走拼团路线，拼团标识_单独购买或团购_单独购买价格_团购价_活动id_团id

if( !empty($_POST['is_collage_product']) ){
	$is_collage_product_info = $configutil->splash_new($_POST["is_collage_product"]);
	$_SESSION['is_collage_product_'.$user_id] = $is_collage_product_info;
} else {
	$is_collage_product_info = $_SESSION['is_collage_product_'.$user_id];
}
$is_collage_product = 0;	//团购产品

$is_collage_product_arr = explode("_",$is_collage_product_info);
$is_collage_product = $is_collage_product_arr[0];//拼团标识

$group_buy_type = 0;		//1：单独购买，2：团购
$single_price = 0;			//单独购买价格
$group_price = 0;			//团购价
$activitie_id = -1;			//活动id
$group_id = -1;				//团id
$is_use_free_coupon = 0;		//是否可以使用团长免单券，1是，0否
$if_bbt = 0;       //是否抱抱团，1是，0否
$if_bbt_curr_use = 0;       //抱抱团团长首次开团能否使用购物币，1可以，0不可以
$join_bbt_times = 0;        //用户开团次数（同一个抱抱团活动）
$collage_type = 0;	//拼团类型
$shopcode_onoff = 0;//拼团购物币开关
$shopcode_limit = 1;//拼团能用购物币的身份，1-仅团长 2-仅团员 3-团长和团员
$shopcode_precent = 0;   //拼团购物币抵购比例
$coupon_onoff = 0;//拼团优惠券开关
if( $is_collage_product>0 ){
	$collage_product = explode('_',$is_collage_product_info);
	$is_collage_product = $collage_product[0];
	$group_buy_type = $collage_product[1];
	$single_price = $collage_product[2];
	$group_price = $collage_product[3];
	$activitie_id = $collage_product[4];
	$group_id = $collage_product[5];
	if( $is_collage_product == 1 && $group_buy_type == 2 && $group_id < 0 ){
		$is_use_free_coupon = 1;
	}
    
    /* 查找拼团后台设置  start*/
	    $condition = array(
	        'customer_id' => $customer_id,
	        'isvalid' => true,
	        'id' => $activitie_id
	    );
	    $field = " type,if_curr_pay,shopcode_onoff,shopcode_limit,shopcode_precent,coupon_onoff ";
	    $activity_info = $collageActivities -> getActivitiesMes($condition,$field)['data'][0];
    /* 查找拼团后台设置  end*/
    $shopcode_onoff = $activity_info['shopcode_onoff'];
    $shopcode_limit = $activity_info['shopcode_limit'];
    $shopcode_precent = $activity_info['shopcode_precent'];
    $coupon_onoff = $activity_info['coupon_onoff'];

    if ($is_collage_product) {

	    $collage_type = $activity_info['type'];

	    /* 用户用户开团次数  start */
	    if($activity_info['type'] == 5){
	        $if_bbt = 1;
	        $condition = " ccot.activitie_id=".$activitie_id." AND ccot.user_id=".$user_id." AND ccot.customer_id=".$customer_id." AND ccot.is_head=1 AND ccot.isvalid=true ";
	        $filed = " count(ccot.id) as join_bbt_times ";
	        $user_ccot_info = $collageActivities->get_crew_order($condition,$filed)['batchcode'][0];
	        $join_bbt_times = $user_ccot_info['join_bbt_times'];
	    }
	    /* 用户用户开团次数  end */

	    if($join_bbt_times == 0 && $activity_info['type'] == 5){//用户首次参与该抱抱团活动
	        //抱抱团设置：团长首次开团可使用购物币
	        if( $is_collage_product == 1 && $group_buy_type == 2 && $group_id < 0 && $activity_info['type'] == 5 && $activity_info['if_curr_pay'] == 2){
	            $if_bbt_curr_use = 1;
	        }
	    }
	/*     $head_id = -1;
	    $queryg = "select head_id from collage_group_order_t where id=".$group_id;
		$resg    = _mysql_query($queryg) or die('queryg failed: ' . mysql_error());
		while ($rowg  = mysql_fetch_object($resg))
	    {
	        $head_id = $rowg->head_id;
	    } */

	    //var_dump($activity_info);
	    //echo $join_bbt_times."---";
	    //echo $if_bbt_curr_use;
	}
}

/* 验证首次推广奖励 start */
$check_first_extend = 0;	//是否符合首次推广奖励
if(!empty($_POST["check_first_extend"])){
	$check_first_extend = $configutil->splash_new($_POST["check_first_extend"]);
	$_SESSION['check_first_extend_'.$user_id] = $check_first_extend;
}else if( !empty($_SESSION['check_first_extend_'.$user_id]) ){
	$check_first_extend = $_SESSION['check_first_extend_'.$user_id];
}

/* 验证首次推广奖励 end */

/* 预配送时间 */
$delivery_time = '';
if( !empty($_POST["delivery_time"]) ){
	$delivery_time = $configutil->splash_new($_POST["delivery_time"]);    //预配送时间
	$_SESSION['delivery_time_'.$user_id] = $delivery_time;
} else if ( !empty($_SESSION['delivery_time_'.$user_id]) ) {
	$delivery_time = $_SESSION['delivery_time_'.$user_id];
}
/* 预配送时间 */


/* 是否虚拟产品 start */
$is_virtual = 0;	//是否虚拟产品
$is_first_extend = 0;	//是否首次推广奖励产品
$extend_money 	 = 0;	//首次推广奖励金额

if(!empty($pid)){
	$query_virtual = "SELECT is_virtual FROM weixin_commonshop_products WHERE id=".$pid;
	$result_virtual = _mysql_query($query_virtual) or die("Query_virtual failed:".mysql_error());
	while ( $row_virtual = mysql_fetch_object($result_virtual) ){
		$is_virtual = $row_virtual -> is_virtual;

		$_SESSION['is_virtual_'.$user_id] = $is_virtual;
	}

	if( $check_first_extend == 1 ){	//验证是否为首次推广奖励产品
		$query_extend = "SELECT is_first_extend,extend_money FROM weixin_commonshop_products WHERE id=".$pid;
		$result_extend = _mysql_query($query_extend) or die('Query_extend failed:'.mysql_error());
		while( $row_extend = mysql_fetch_object($result_extend) ){
			$is_first_extend = $row_extend -> is_first_extend;
			$extend_money 	 = $row_extend -> extend_money;
		}

		if( $is_first_extend != 1 ){	//不符合首次推广奖励
			$check_first_extend = 0;
		}
	}

}

if( !empty($_SESSION['is_virtual_'.$user_id]) ){
	$is_virtual = $_SESSION['is_virtual_'.$user_id];
}
/* 是否虚拟产品 end */

//单个产品--end

//购物车数据-----start

$pro_arr 	= '';
$clean_cart = '';//记录购物车传来的数据，用于清除购物车记录
if(!empty($_POST["pro_arr"])){
    $pro_arr  	= $_POST["pro_arr"]; 	//不使用防注入
	$clean_cart	= $pro_arr;
}
$pro_arr = json_decode($pro_arr);


//购物车数据-----start

$fromtype = -1; //1:立即购买 2:购物车购买

if(!empty($_POST["fromtype"])){
    $fromtype      = $configutil->splash_new($_POST["fromtype"]);
    $_SESSION['fromtype'] = $fromtype;		//第一次存入session，下次直接读session
}else{
	$fromtype = $_SESSION['fromtype'] ;
}



/***************************会员卡折扣可以选择模式与优惠券 暂不用*********************************/
/*
//----选择会员卡后返回的card_id和信息（余额、积分、折扣,名称）
$select_card_id = '-1';
$rtn_card_array = '';
if(!empty($_POST["select_card_id"])){
    $select_card_id   = $configutil->splash_new($_POST["select_card_id"]);
    $rtn_card_array   = $configutil->splash_new($_POST["rtn_card_array"]);
	$rtn_card_array   =  explode(',',$rtn_card_array);
	//设置session方便以后跳转读取
	$_SESSION['select_card_id_'.$user_id] = $select_card_id;
	$_SESSION['rtn_card_array_'.$user_id] = $rtn_card_array;


   //注销优惠券的session
   unset($_SESSION['select_coupon_id_'.$user_id]);
   unset($_SESSION['rtn_coupon_array_'.$user_id]);
}else{
	$select_card_id   		  = $_SESSION['select_card_id_'.$user_id];
    $rtn_card_array   		  = $_SESSION['rtn_card_array_'.$user_id];
}
//var_dump($rtn_card_array);
//----选择会员卡后返回的card_id和信息（余额、积分、折扣


//----选择优惠券后返回的id和信息（使用金额限制、优惠金额）
$select_coupon_id = '-1';
$rtn_coupon_array = '';
if(!empty($_POST["select_coupon_id"])){
    $select_coupon_id   = $configutil->splash_new($_POST["select_coupon_id"]);
    $rtn_coupon_array   = $configutil->splash_new($_POST["rtn_coupon_array"]);
	$rtn_coupon_array   =  explode(',',$rtn_coupon_array);
	//设置session方便以后跳转读取
	$_SESSION['select_coupon_id_'.$user_id] = $select_coupon_id;
	$_SESSION['rtn_coupon_array_'.$user_id] = $rtn_coupon_array;
	//var_dump($rtn_coupon_array);

	//注销会员卡的的session
    unset($_SESSION['select_card_id_'.$user_id]);
    unset($_SESSION['rtn_card_array_'.$user_id]);
	$select_card_id   		      = $_SESSION['select_card_id_'.$user_id];  		//重新赋值，解决选择优惠券后也会现在会员卡
    $rtn_card_array   		  	  = $_SESSION['rtn_card_array_'.$user_id];			//重新赋值，解决选择优惠券后也会现在会员卡
}else{
	$select_coupon_id   		  = $_SESSION['select_coupon_id_'.$user_id];
    $rtn_coupon_array   		  = $_SESSION['rtn_coupon_array_'.$user_id];

}

//----选择优惠券后返回的id和信息（使用金额限制、优惠金额）
*/

/***************************会员卡折扣可以选择模式与优惠券 暂不用*********************************/


//----选择送货时间返回的id和信息（id、送货时间详情）
$sendtime_id = '-1';

$rtn_sendtime_array = '';
if(!empty($_POST["sendtime_id"])){
    $sendtime_id   		  = $configutil->splash_new($_POST["sendtime_id"]);
    $rtn_sendtime_array   = $configutil->splash_new($_POST["rtn_sendtime_array"]);
	$rtn_sendtime_array   =  explode(',',$rtn_sendtime_array);
	//设置session方便以后跳转读取，会在保存订单页面清除
	$_SESSION['sendtime_id_'.$user_id] = $sendtime_id;
	$_SESSION['rtn_sendtime_array_'.$user_id] = $rtn_sendtime_array;
	//var_dump($rtn_sendtime_array);

}else{
	$sendtime_id   		  = $_SESSION['sendtime_id_'.$user_id];
    $rtn_sendtime_array   = $_SESSION['rtn_sendtime_array_'.$user_id];
}
//----选择送货时间返回的id和信息（id、送货时间详情）


//----选择自定义区域返回的id和信息（id、送货时间详情）
$diy_area_id = -1;
$rtn_diy_area_array = '';
if(!empty($_POST["diy_area_id"])){
    $diy_area_id   		  = $configutil->splash_new($_POST["diy_area_id"]);
    $rtn_diy_area_array   = $configutil->splash_new($_POST["rtn_diy_area_array"]);
	$rtn_diy_area_array   =  explode(',',$rtn_diy_area_array);
	//设置session方便以后跳转读取，会在保存订单页面清除
	$_SESSION['diy_area_id_'.$user_id] = $diy_area_id;
	$_SESSION['rtn_diy_area_array_'.$user_id] = $rtn_diy_area_array;
	//var_dump($rtn_diy_area_array);

}else{
	$diy_area_id   		  = $_SESSION['diy_area_id_'.$user_id];
    $rtn_diy_area_array   = $_SESSION['rtn_diy_area_array_'.$user_id];
}
//----选择自定义区域返回的id和信息（id、送货时间详情）


/***************************重组数据 start******************************/
/*
POST过来的数据结构说明：
例子：
购物车
{
	"-1":[["1510","1253_1413","10"],
	"191155":[["1510","1253_1413","10"],
	"191566":[["1510","1253_1413","10"],
	"-1":[["1510","1253_1413","10"]
]}
供应商ID1:[产品ID,所选属性,数量]
供应商ID2:[产品ID,所选属性,数量]
供应商ID3:[产品ID,所选属性,数量]

单品购买
["1510","1253_1413","10","124","198119"]--[产品ID,所选属性,fromtype,数量,供应商ID]

*/


/**	$is_active_product 活动产品字符串 类型拼接活动id  $act_type_$act_id

	$pro_act_id		活动编号
	$pro_act_type	10~19 拼团
	$pro_act_type	20~29 积分   21商城送积分 22兑换活动  23门店送积分
	$pro_act_type	30~39 限购
	$pro_act_type	40~49 砍价
	$pro_act_type	50~59 众筹

**/
$act_type = -1;
$act_id = -1;
if(!empty($_POST['is_active_product'])){
	$is_active_product = $_POST['is_active_product'];
	$active_product = explode('_',$is_active_product);
	$act_type = $active_product[0];
	$act_id = $active_product[1];
}


/*测试积分数据star*/
/*$act_type = 2;
$act_id = 1;
$fromtype = 2;
$pro_arr = [
[-1,[5395,2395,1,-1,'',2,1]],
[-1,[5470,2396,1,-1,'',2,1]],

];*/

// 非地址页面||优惠券页面进入清除$_SESSION
if( $_REQUEST['aid'] || $_REQUEST['cid']  || $_REQUEST['eid'] ){
    // echo 123;
}else{
    unset($_SESSION['exchange_'.$user_id]);
}
// var_dump($_SESSION['exchange_'.$user_id]);
// 筛选不满足满赠条件的满赠商品
$price = $_REQUEST['platform_price'];
if( $price ){
    $exchange_list = count(json_decode($_SESSION['exchange_'.$user_id])) ? $_SESSION['exchange_'.$user_id] : $_REQUEST['exchange'];
    $exchange_list = json_decode($exchange_list);
    if( count($exchange_list) > 0 ){
        foreach ($exchange_list as $key => $value) {
            $pid = $value[1][0];
            $exchange_id = $value[1][8];
            require_once($_SERVER['DOCUMENT_ROOT'].'/mshop/admin/model/exchange.php');
            $exchange_m = new model_exchange($customer_id);
            $threshold = $exchange_m->get_exchange_threshold($exchange_id);
            if( $price < $threshold ){
                $del[] = $key;
            }
        }
        foreach ($del as $key => $value) {
            $exchange_lists = array_splice($exchange_list,$value+1,1);
        }
        $_REQUEST['exchange'] = json_encode($exchange_lists);
        $_SESSION['exchange_'.$user_id] = json_encode($exchange_lists);
    }
}

//var_dump($pro_arr);
/*测试积分数据end*/
 if($fromtype ==1 ){		//立即购买
	$topic_arr = '';
	if( $resource_id > 0 ){
		$topic_arr = 'resourceid_'.$resource_id;
	}elseif( $topic_id > 0 ){
		$topic_arr = 'topicid_'.$topic_id;
	}
	 $buy_now = array($supply_id, array($pid,$prvalues,$rcount,$topic_arr,$is_collage_product_info,$act_type,$act_id));//转成购物车数组结构，方便操作--  供应商ID:[产品ID,所选属性,数量,直播房间id]
	 $bug_post_data = $buy_now;								//需要添加邮费的数据
	//-----------当post数据没有就读取session
	if($_POST['pid']==''){
			$bug_post_data = $_SESSION['bug_post_data_'.$user_id];
	}
	//-----------当post数据没有就读取session
    $_SESSION['bug_post_data_'.$user_id] = $bug_post_data;  //立即购买和购物车数据加入session
   	//var_dump($_SESSION['bug_post_data_'.$user_id]);
    $buy_array = make_arr(1,$bug_post_data,1); //立即购买（带自定义键名）

	/*sz郑培强添加用于砍价活动--start*/
	if($_POST['form_bargain_sz']){
		$_SESSION['form_bargain_sz']=$_POST['form_bargain_sz'];
		$_SESSION['form_bargain_sz_data']=$_POST['form_bargain_sz_data'];
		$_SESSION['rcount']=$_POST['rcount'];
		$_SESSION['sel_pros']=$_POST['sel_pros'];
		$_SESSION['supply_id']=$_POST['supply_id'];
		$form_bargain_sz=$_POST['form_bargain_sz'];
		$form_bargain_sz_data=$_POST['form_bargain_sz_data'];
	}
	if($_SESSION['form_bargain_sz']){
		$form_bargain_sz=$_SESSION['form_bargain_sz'];
		$rcount=$_SESSION['rcount'];
		$prvalues=$_SESSION['sel_pros'];
		$form_bargain_sz=$_SESSION['form_bargain_sz'];
		$form_bargain_sz_data=$_SESSION['form_bargain_sz_data'];
		$supply_id=$_SESSION['supply_id'];
		$bug_post_data=array($supply_id, array($pid,$prvalues,$rcount,$live_room_id,$is_collage_product_info,$form_bargain_sz));
		//var_dump($bug_post_data);
		$buy_array=make_arr_bargain(1,$bug_post_data,1);
	}
	/*sz郑培强添加用于砍价活动--end*/

	/*sz郑培强添加用于众筹活动--start*/
	if($_POST['form_crowdfund_sz']){
		$_SESSION['form_crowdfund_sz']=$_POST['form_crowdfund_sz'];
		$_SESSION['form_crowdfund_sz_data']=$_POST['form_crowdfund_sz_data'];
		$_SESSION['rcount']=$_POST['rcount'];
		$_SESSION['sel_pros']=$_POST['sel_pros'];
		$_SESSION['supply_id']=$_POST['supply_id'];
		$form_crowdfund_sz=$_POST['form_crowdfund_sz'];
		$form_crowdfund_sz_data=$_POST['form_crowdfund_sz_data'];
	}
	if($_SESSION['form_crowdfund_sz']){
		$form_crowdfund_sz=$_SESSION['form_crowdfund_sz'];
		$rcount=$_SESSION['rcount'];
		$prvalues=$_SESSION['sel_pros'];
		$form_crowdfund_sz=$_SESSION['form_crowdfund_sz'];
		$form_crowdfund_sz_data=$_SESSION['form_crowdfund_sz_data'];
		$supply_id=$_SESSION['supply_id'];
		$bug_post_data=array($supply_id, array($pid,$prvalues,$rcount,$live_room_id,$is_collage_product_info,$form_crowdfund_sz));
		//var_dump($bug_post_data);
		$buy_array=make_arr_bargain(1,$bug_post_data,1);
	}
	/*sz郑培强添加用于众筹活动--end*/
    $buy_array_add_express = make_arr(1,$bug_post_data,2);

    /*满赠换购活动合并购物车 START*/
    $exchange_list = count(json_decode($_SESSION['exchange_'.$user_id])) ? $_SESSION['exchange_'.$user_id] : $_REQUEST['exchange'];
    if( $exchange_list ) {
        /*$exchange_list = json_decode($exchange_list);
        $exchange = $exchange_list;
        foreach ($exchange as $key => &$value) {
            array_splice($exchange[$key][1],6,1);
        }*/

        $bug_post_dataa[] = $bug_post_data;
        $bug_post_datas = array_merge($bug_post_dataa,json_decode($exchange_list));
        $bug_post_data = $bug_post_datas;
        $buy_array = make_arr(1,$bug_post_data,3);
        $buy_array_add_express = make_arr(1,$bug_post_data,4);
    }
    /*满赠换购活动合并购物车 END*/
	//立即购买和购物车的原始数据进行二次添加邮费，组合成新的数据
 }elseif($fromtype == 2){	//购物车
	 $bug_post_data = $pro_arr;								//需要添加邮费的数据
	 //-----------当post数据没有就读取session
	if($_POST['pro_arr']==''){
			$bug_post_data = $_SESSION['bug_post_data_'.$user_id];
			$clean_cart	   = json_encode( $bug_post_data );
	}
	//-----------当post数据没有就读取session
    $_SESSION['bug_post_data_'.$user_id] = $bug_post_data;  //立即购买和购物车数据加入session
    /*满赠换购活动合并购物车 START*/
    $exchange_list = count(json_decode($_SESSION['exchange_'.$user_id])) ? $_SESSION['exchange_'.$user_id] : $_REQUEST['exchange'];
    if( $exchange_list ) {
        $bug_post_datas = array_merge($bug_post_data,json_decode($exchange_list));
        $bug_post_data = $bug_post_datas;
    }
    /*满赠换购活动合并购物车 END*/
    $buy_array = make_arr(2,$bug_post_data,1);
    //购物车数据处理（带自定义键名）
    //合并满赠产品
    $buy_array_add_express = make_arr(2,$bug_post_data,2);  //立即购买和购物车的原始数据进行二次添加邮费，组合成新的数据
 }
 $_SESSION['exchange_'.$user_id] = $exchange_list;

/*------------使用购物车测试数据--------------*/
/* $a =  array('-1', array(1510,'1253_1413',2));
$a2 =  array('-1',array(1510,'1253_1412',1));
$a3 =  array('191099',array(766,'',3));
$a4 =  array('191099',array(1285,'1088_1137',4));
$a5 =  array('195461',array(913,'',5));

 $_A = [$a ,$a2 ,$a3 ,$a4,$a5 ];
 $_A2 = [$a ,$a2 ,$a ,$a ];


 $bug_post_data = $_A;
 $buy_array = make_arr(2,$_A,1);				//购物车数据处理成带键名数组
 $buy_array_add_express = make_arr(2,$bug_post_data,2);	//购物车数据处理成以供应商ID分类的数组 */
/*------------使用购物车测试数据--------------*/


/***************************重组数据 end******************************/



//-------商城基本设置  start----------//
//支付方式开关
$is_alipay    = false;				//支付宝支付开关
$is_weipay    = false;				//商城微信支付开关
$is_tenpay    = false;				//商城财付通开关
$is_allinpay  = false;				//商城通联支付开关
$is_payChange = false;				//零钱支付开关
$is_pay       = false;				//暂不支付开关
$isdelivery   = false;				//商城代付开关0关闭1开启
$iscard       = false;				//商城会员卡支付开关
$isshop       = false;				//商城到店支付开关
$is_payother  = false;				//是否开启代付
$is_paypal	  = false;				//paypal支付
$isOpenCurrency = false;			//购物币支付开关

$is_yeepay	  = false;				//paypal支付
$query = 'SELECT id,is_alipay,is_tenpay,is_weipay,is_pay,is_payChange,is_allinpay,isdelivery,iscard,isshop,is_payother,is_paypal,is_yeepay,is_jdpay FROM customers where isvalid=true and id='.$customer_id;
$defaultpay = "";
$result = _mysql_query($query) or die('W75 Query failed: ' . mysql_error());
while ($row = mysql_fetch_object($result)) {
    $is_alipay    = $row->is_alipay;
	$is_tenpay    = $row->is_tenpay;
	$is_weipay    = $row->is_weipay;
	$is_payChange = $row->is_payChange;
	$is_pay       = $row->is_pay;
	$is_allinpay  = $row->is_allinpay;
	$iscard       = $row->iscard;
	$isdelivery   = $row->isdelivery;
	$isshop       = $row->isshop;
	$is_payother  = $row->is_payother;
	$is_paypal    = $row->is_paypal;
	$is_yeepay    = $row->is_yeepay;
	$is_jdpay     = $row->is_jdpay;
	break;
}


$member_template_type =1;	//申请推广员模式
$nopostage_money      =0;   //订单多少可以免邮
$exp_name 			  = "推广员";
$is_identity 		  = 0;	//是否开启身份证验证
$is_coupon 			  = 0;
$sendstyle_express    = 1;
$sendstyle_pickup     = 0;
$shop_card_id         = -1;
$issell_model		  = 0;
$is_uploadidentity	  = 0;	//是否上传身份证附件
$is_ban_use_coupon_currency = 0;//是否禁止同时使用购物币和优惠券
$query="select member_template_type,nopostage_money,exp_name,is_identity,is_ban_use_coupon_currency,is_coupon,sendstyle_express,sendstyle_pickup,shop_card_id,is_uploadidentity,issell_model from weixin_commonshops where isvalid=true and customer_id=".$customer_id;
$result = _mysql_query($query) or die('w93 Query failed: ' . mysql_error());
while ($row = mysql_fetch_object($result)) {
   $member_template_type = $row->member_template_type;
   $nopostage_money 	 = $row->nopostage_money;
   $exp_name 			 = $row->exp_name;           //推广员名称
   $is_identity			 = $row->is_identity;        //身份证限制
   $is_uploadidentity    = $row->is_uploadidentity;	 //是否上传身份证附件
   $is_coupon			 = $row->is_coupon;          //是否开启优惠券 1:开启 0:关闭
   $sendstyle_express	 = $row->sendstyle_express;  //是否开启配送方式快递 1:开启 0:关闭
   $sendstyle_pickup	 = $row->sendstyle_pickup;   //是否开启配送方式自提 1:开启 0:关闭
   $shop_card_id	     = $row->shop_card_id;       //商城所用到的会员卡
   $issell_model	     = $row->issell_model;       //'1:顶级推广员购买返佣;2:只要是推广员,都有返佣', 复购
   $is_ban_use_coupon_currency = $row->is_ban_use_coupon_currency;  //是否禁止同时使用购物币和优惠券
}
$total_is_Pinformation = 0;//必填信息总开关开关
$is_shop_deductible = 0;//'是否使用店铺奖励抵扣'
$is_extension_deductible = 0;//是否使用推广奖励抵扣
$query="select is_Pinformation,is_shop_deductible,is_extension_deductible from weixin_commonshops_extend where isvalid=true and customer_id=".$customer_id;
$result = _mysql_query($query) or die('w93 Query failed: ' . mysql_error());
while ($row = mysql_fetch_object($result)) {
   $total_is_Pinformation 	= $row->is_Pinformation;
   $is_shop_deductible 		= $row->is_shop_deductible;
   $is_extension_deductible = $row->is_extension_deductible;
}
//郑培强 添加用于 砍价众筹 不开启复购 开始
if($_SESSION['form_bargain_sz'] || $_SESSION['form_crowdfund_sz']){
	$issell_model == 1;
}
//郑培强 添加用于 砍价众筹 不开启复购 结束
/*不开启复购则取消3级分销奖励和店铺奖励抵扣*/
if($issell_model !=2 ){
	 $is_shop_deductible 		= 0;
	 $is_extension_deductible   = 0;
}



$query = "SELECT id,name,phone,address,type,user_info,door_num,cargo_time,zusername from weixin_users where isvalid=true and  id=".$user_id;
$result = _mysql_query($query) or die('w126 Query failed: ' . mysql_error());
while ($row = mysql_fetch_object($result)) {
	$username    = $row->name;
	$userphone   = $row->phone;
	$useraddress = $row->address;
	$user_type   = $row->type;
	$user_info   = $row->user_info;//20180722 By Code048
	$door_num    = $row->door_num;
	$cargo_time  = $row->cargo_time;
	$zusername   = $row->zusername;
	break;
}
//echo $username;

//查询是否开启购物币支付
$sel_curr_sql = "SELECT isOpen,custom FROM weixin_commonshop_currency WHERE customer_id=".$customer_id;
$sel_curr_res = _mysql_query($sel_curr_sql);
while( $info = mysql_fetch_object($sel_curr_res) ){
	$isOpenCurrency = $info->isOpen;
	$custom 		= $info->custom;

}




//---------商城基本设置  end ------------//

/*-------查找个人购物币-------*/
$user_currency = 0;

$query_curr_user = "select currency from weixin_commonshop_user_currency where isvalid=true and customer_id=".$customer_id." and user_id=".$user_id." order by id asc limit 1";
$result_curr_user=_mysql_query($query_curr_user)or die('Query failed'.mysql_error());
while($row_curr_user=mysql_fetch_object($result_curr_user)){
	$user_currency = $row_curr_user->currency;
}
$user_currency	= cut_num($user_currency,2);
/*-------查找个人购物币-------*/


/*-------收货信息-------*/

			$add_keyid   = -1;
			$add_name    = "";	//收货人名字
			$add_phone   = "";	//收货人电话
			$identity    = "";	//收货人身份证
			$identityimgt="";
			$identityimgf="";
			$address     = "";	//收货人地址
			$location_p  = "";	//省
			$location_c  = "";	//市
			$location_a  = "";	//区
			$address_str = "";	//详细地址
			$is_default  = 0;	//是否为默认地址 0不是 1是
            //+ 韦 14:41 2016/9/3 未定义
            $default_diy_areaname = '';
            //+ 韦 14:41 2016/9/3 未定义
            $default_diy_area_id = -2;
            $address_detail = "";

		if ( $is_virtual != 1){	//虚拟产品不需要收货地址
			if($aid>0){
				$query="select id,name,phone,address,location_p,location_c,location_a,is_default,identity,identityimgt,identityimgf,detail_address from weixin_commonshop_addresses where isvalid=true and user_id=".$user_id."  and id =".$aid;
			}else{
				$query="select id,name,phone,address,location_p,location_c,location_a,is_default,identity,identityimgt,identityimgf,detail_address from weixin_commonshop_addresses where isvalid=true and user_id=".$user_id." and is_default = 1";
			}
			//echo $query;
			$old_p_arr = array();
			$old_c_arr = array();
			$old_a_arr = array();
			$result = _mysql_query($query) or die('Query failed: ' . mysql_error());
			while ($row = mysql_fetch_object($result)) {
				$add_keyid   = $row->id;
				$add_name    = $row->name;
				$add_name = htmlspecialchars($add_name);
				$add_phone   = $row->phone;
				$address     = $row->address;
				$detail_address = $row->detail_address;
                $address = str_replace(array("\r\n", "\r", "\n"), '', $address);
				$address = htmlspecialchars($address,ENT_QUOTES);
//                echo "--".$address."--";
				// $identity    = $row->identity;	//身份证
				// $identityimgt= $row->identityimgt;
				// $identityimgf= $row->identityimgf;
				$location_p  = $row->location_p;
				$location_c  = $row->location_c;
				$location_a  = $row->location_a;
				$old_p_arr[] = $location_p;
				$old_c_arr[] = $location_c;
				$old_a_arr[] = $location_a;
				$address_str = $location_p." ".$location_c." ".$location_a." ".$address;
				$address_detail = $location_p.$location_c.$location_a.$address;
				$address_detail = addslashes(str_replace(array("\r\n","\n"),'',$address_detail));
//                echo "--".$address_detail."--";
			}

			$query_identity = "select identity,identityimgt,identityimgf from weixin_commonshop_identity_info where isvalid=true and user_id=".$user_id." and name='".mysql_real_escape_string($add_name)."'";
			$result_identity = _mysql_query($query_identity) or die('Query_identity failed:'.mysql_error());
			while($row_identity = mysql_fetch_object($result_identity)){
				$identity 	  = $row_identity->identity;
				$identityimgt = $row_identity->identityimgt;
				$identityimgf = $row_identity->identityimgf;
			}
			$sum_ID_tf = 0;
			if($add_keyid>0){
				$sum_ID_tf = ((empty($identityimgt)) ? 0:1)	+  ((empty($identityimgf) ? 0:1));	//记录用户的地址信息是否已经上传了身份证证正反面
			}

			//8.2.2_P2版本对地址库进行了更新，需要判断以前添加的区域是否需要更新，然后提示用户重新设置，否则将影响区域奖励模式
			$area_str = '';
			foreach($old_p_arr as $k=>$v){
				$area_id = -1;
				$query_o = "select ID from address where Name='".$v."' and LevelType=1 limit 1";
				$result_o = _mysql_query($query_o) or die('L303 Query failed: ' . mysql_error());
				while($row_o = mysql_fetch_object($result_o)) {
					$area_id = $row_o->ID;
				}
				if($area_id<0){
					$area_str .= $v.',';
				}
			}
			foreach($old_c_arr as $k=>$v){
				$area_id = -1;
				$query_o = "select ID from address where Name='".$v."' and LevelType=2 limit 1";
				$result_o = _mysql_query($query_o) or die('L303 Query failed: ' . mysql_error());
				while($row_o = mysql_fetch_object($result_o)) {
					$area_id = $row_o->ID;
				}
				if($area_id<0){
					$area_str .= $v.',';
				}
			}
			foreach($old_a_arr as $k=>$v){
				$area_id = -1;
				$query_o = "select ID from address where Name='".$v."' and LevelType=3 limit 1";
				$result_o = _mysql_query($query_o) or die('L303 Query failed: ' . mysql_error());
				while($row_o = mysql_fetch_object($result_o)) {
					$area_id = $row_o->ID;
				}
				if($area_id<0){
					$area_str .= $v.',';
				}
			}
			$area_str = rtrim($area_str,',');
		}
/*-------收货信息-------*/

/*-------自定义区域-------*/

		$is_diy_area  = 0;
		$Query_isArea = "SELECT is_diy_area,diy_customer from weixin_commonshop_team WHERE isvalid = true AND customer_id = ".$customer_id." limit 0,1";
		$Result_isArea = _mysql_query($Query_isArea) or die (" w860 : Query_isArea failed : ".mysql_error());
		if($row_isArea = mysql_fetch_object($Result_isArea)){
			$is_diy_area  =  $row_isArea->is_diy_area;
		}
		if($is_diy_area && !empty($location_p)){
			$areaArray = array();
			$default_diy_area_id_f = -2;
			$default_diy_area_id = -2;
			$default_diy_areaname_f = '';
			$default_diy_array = array();
			$default_diy_areaname = '';
			$diy_areaname_length = 0;
			$Query_diyArea = "SELECT id,areaname from weixin_commonshop_team_area WHERE isvalid = true and customer_id = ".$customer_id." and grade = 3 and all_areaname like '" . $location_p.$location_c.$location_a. "%' ";
			$Result_diyArea = _mysql_query($Query_diyArea) or die (" w867 : Query_diyArea failed : ".mysql_error());
			while ($row_diyArea = mysql_fetch_object($Result_diyArea)) {

				$default_diy_area_id_f = $row_diyArea->id;
				$default_diy_areaname_f = $row_diyArea->areaname;
				//条件1：收货地址含有自定义地址；条件2：取自定义地址长度最长的
				if( strpos( $default_diy_areaname_f , $address ) !== false && strlen($default_diy_areaname_f) > $diy_areaname_length ){
					$default_diy_area_id = $default_diy_area_id_f;
					$default_diy_areaname = $default_diy_areaname_f;
					$diy_areaname_length = strlen($default_diy_areaname_f);
				}
			}

		}
/*-------自定义区域-------*/

if ( 1 == $is_virtual ){	//虚拟产品不需要身份证验证、配送方式、自定义区域
	$is_identity 		= 0;
	$is_uploadidentity 	= 0;
	$sendstyle_express 	= 0;
	$sendstyle_pickup 	= 0;
	$is_diy_area 		= 0;
}

/*-------查询是否有运费模板-------*/

$tmp_cout = 0;
$query = "select count(1) as tmp_cout from express_template_t where isvalid=true and customer_id=".$customer_id."";
$result=_mysql_query($query)or die('Query failed'.mysql_error());
while($row=mysql_fetch_object($result)){
	$tmp_cout = $row->tmp_cout;
}
/*-------查询是否有运费模板-------*/

 /*------------立即购买和购物车重组数据--------------*/
$supply_express 			= '';
$buy_all_data 				= regroup_data_array($buy_array);			//POST数组重组对应的产品信息
$buy_all_data_json 			= json_encode($buy_all_data);				//用于显示产品详情的数据
foreach ($del_exchange as $key => $value) {
    array_splice($buy_array_add_express,$value,1);
}
$buy_array_add_express_json = json_encode($buy_array_add_express);		//用于保存订单的数据
$supply_express_json 		= json_encode($supply_express);				//8.0.0.1 版本快递数组
//提交表单的数据
/*------------立即购买和购物车重组数据--------------*/

/*-------------查询正在使用的优惠券-------------*/
//查询当前已点击的优惠券
	$sql = "select couponusers_id from weixin_commonshop_coupon_using where isvalid=true and customer_id=".$customer_id." and user_id=".$user_id;
	$result = _mysql_query($sql) or die('selectUsing Query failed: ' . mysql_error());
	$usingStr = '';
	while ($row = mysql_fetch_object($result)) {
		$usingStr .= $row->couponusers_id.",";
	}
	$usingStr = substr($usingStr,0,strlen($usingStr)-1);
/*-------------查询正在使用的优惠券-------------*/

/*-------------查询是否已经设置了支付密码-------------*/
$show_pay_way = new show_pay_way($customer_id);
$check_pay_password = $show_pay_way->check_pay_password($customer_id,$user_id);




/*-------------查询是否已经开启货到付款设置-------------*/
foreach ($buy_all_data as $k => $v)
{
	foreach($v as $a=>$b)
	{
		$pids[] = $b['pid'];
	}
}
foreach($pids as $k=>$v)
{
	if(!$v)
	{
		unset($pids[$k]);
	}
}

$limit       = count($pids);
$im_pids     = implode($pids, ',');
$delivery_sql= "select id,pid from pay_on_delivery_products_t where pid in($im_pids) and isvalid=1 limit $limit";
$delivery_oi = _mysql_query($delivery_sql) or die('Query failed: ' . mysql_error());
while ($row  = mysql_fetch_object($delivery_oi))
{
   $copay_on = $row->id;
   $copay[$row->pid]  = $copay_on;
}

if(count($copay) == count($pids))
{
	$delivery_on = 1;
}

$is_delivery = "select is_pay_on_delivery from weixin_commonshops_extend where isvalid=1 and customer_id=$customer_id";
$delivery    = _mysql_query($is_delivery) or die('Query failed: ' . mysql_error());
while ($row  = mysql_fetch_object($delivery))
{
   $ispay_on = $row->is_pay_on_delivery;
}
//查询是否开启商城积分 或者 门店积分
$shop_integral_onoff  = 0;			//商城
$store_integral_onoff = 0;			//门店
$using_exchange_type  = 0;			//正在使用的兑换类型 0商城  1门店
$integral_setting="SELECT shop_onoff, store_onoff,basic_json,store_json FROM ".WSY_SHOP.".integral_setting WHERE cust_id='{$customer_id}'";
$res_integral_setting= _mysql_query($integral_setting) or die('integral_onoff failed:'.mysql_error());
$shop_int_name  = '商城积分';
$store_int_name = '门店积分';
while($row_inte = mysql_fetch_object($res_integral_setting)){
	$shop_integral_onoff  =$row_inte->shop_onoff;
	$store_integral_onoff =$row_inte->store_onoff;

	$shop_set 	= json_decode($row_inte->basic_json,TRUE);
	$store_set  = json_decode($row_inte->store_json,TRUE);

	$shop_int_name  = !empty($shop_set['integral_name'])?  $shop_set['integral_name']  :'商城积分';
	$store_int_name = !empty($store_set['integral_name'])? $store_set['integral_name'] :'门店积分';
}

if($shop_integral_onoff == 0 ){
	$using_exchange_type = 1;
}

if(!empty($_COOKIE['using_exchange_type_'.$user_id])){
	$using_exchange_type = ($_COOKIE['using_exchange_type_'.$user_id]);
}

//是否开启订货系统门店模式
// $sql = "SELECT a.isopen_shop, b.isopen_proxy FROM " . WSY_DH . ".orderingretail_shop_setting a 
//                 LEFT JOIN orderingretail_setting b ON a.customer_id = b.customer_id 
//                 WHERE a.customer_id='{$customer_id}' AND b.isvalid = TRUE";
// // $res = $this->db->getRow($sql);


//是否开启订货系统门店模式
$is_orderingretail = 0;
$is_orderingretail_store = 0;
$sql = "SELECT a.isopen_shop, b.isopen_proxy FROM orderingretail_shop_setting a 
        LEFT JOIN orderingretail_setting b ON a.customer_id = b.customer_id 
        WHERE a.customer_id='{$customer_id}' AND b.isvalid = TRUE LIMIT 1";
$result = _mysql_query($sql) or die('isopen_shop failed:'.mysql_error());
while ($row = mysql_fetch_object($result)){
    $is_orderingretail = $row->isopen_proxy;
    if ($is_orderingretail){
        $is_orderingretail_store = $row->isopen_shop;
    }

}


?>

<!DOCTYPE html>
<html>
<head>
    <title>确认订单</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta content="no" name="apple-touch-fullscreen">
    <meta name="MobileOptimized" content="320"/>
    <meta name="format-detection" content="telephone=no">
    <meta name=apple-mobile-web-app-capable content=yes>
    <meta name=apple-mobile-web-app-status-bar-style content=black>
    <meta http-equiv="pragma" content="nocache">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
	<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8">


    <link type="text/css" rel="stylesheet" href="./assets/css/amazeui.min.css" />
    <link type="text/css" rel="stylesheet" href="./css/goods/global.css" />
    <link type="text/css" rel="stylesheet" href="./css/goods/querendingdan.css" />
    <link type="text/css" rel="stylesheet" href="./css/order_css/global.css" />
    <link type="text/css" rel="stylesheet" href="./css/password.css" />
	<link rel="stylesheet" id="twentytwelve-style-css" href="./css/goods/dialog.css" type="text/css" media="all">
	<link rel="stylesheet" type="text/css" href="../common/layer/need/layer.css">
	<script type="text/javascript" src="../common/layer/layer.js"></script>
    <link type="text/css" rel="stylesheet" href="./css/css_<?php echo $skin ?>.css" />
	<link rel="stylesheet" href="./css/cui.css" />

	<link rel="stylesheet" href="./css/msgbox.css" /><!--测试-->
    <script type="text/javascript" src="../common/js/jquery-2.1.0.min.js"></script>
	<script type="text/javascript" src="./js/global.js"></script>
	<script type="text/javascript" src="./assets/js/jquery.min.js"></script>
	<script type="text/javascript" src="./assets/js/amazeui.js"></script>
	<script type="text/javascript" src="./js/loading.js"></script>
	<script src="./js/jquery.ellipsis.js"></script>
	<script src="./js/jquery.ellipsis.unobtrusive.js"></script>
</head>
<style>

/*新加的样式*/
*{
    font-family:'微软雅黑';
}
.content-header{
    padding-bottom:10px;
    background:url(./images/color_ribbon.png) no-repeat bottom;
    background-size:100% 3px;
	 overflow:hidden;
    background-color:#FFF;
    position: relative;
}
.content-list{
    margin-top:0px
}
.kong{
    height:10px;
}
.am-navbar{
    height:65px;
}
.white-list .line{
    background-color:#eee;
}
.slide_block{
    position: absolute;
    background: white;
    top: 1px;
    left: 1px;
    z-index: 1100;
    width: 31px;
    -webkit-transition: all 0.1s ease-in;
    transition: all 0.1s ease-in;
    height: 31px;
    border-radius: 100px;
    box-shadow: 0 3px 1px rgba(0,0,0,0.05), 0 0px 1px rgba(0,0,0,0.3);
}
.slide_body{
    position: absolute;
    top: 0;
    -webkit-transition: box-shadow 0.1s ease-in;
    transition: box-shadow 0.1s ease-in;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 100px;
    box-shadow: inset 0 0 0 0 #eee, 0 0 1px rgba(0,0,0,0.4);
}

.input_edit{
    width: 100%;
    height: 60px;
    text-indent: 6px;
	border:0;
}
.input_edit2{
    width: 100%;
    height: 23px;
    text-indent: 6px;
}
.no_info{text-align:center;}
.no_info span{
    font-size: 15px;
    display: inline-block;
    margin-top: -10px;
	}
.no_border{border:0;}
.select_coupon{position:relative;}

.select_coupon_span_r,.select_store_span_r{position:absolute;right: 35px;font-size: 13px !important;}

/*.sharebg-active{z-index:3000;}*/
.layermbtn span{height: 39px;}
.item-row1-left1 .logo-img{width: 25px;height: auto;max-height: 30px;min-height:16px;vertical-align: middle;}

 //ld 点击效果
        .button{
        	-webkit-transition-duration: 0.4s; /* Safari */
        	transition-duration: 0.4s;
        }

        .buttonclick:hover{
        	box-shadow:  0 0 5px 0 rgba(0,0,0,0.24);
        }
		.btn-shui{height: 16px; background: #fff;border:1px solid #ff7109; color: #ff7109;border-radius: 2px;font-size: 12px;padding: 0;}
		   .test5 {
			display: inline-block;
		    height:0;
		    width:20px;
		    color:#fff;
		    line-height: 0;
		    border-color:#ff7109 #fff transparent transparent;
		    border-style:solid solid dashed dashed;
		    border-width:14px 4px 0 0 ;
			}
	      .test5 span{display: block;margin-top: -6px;color: #fff;font-weight: bold;  line-height: 0px;height: 0px;font-size: 12px;}
	      #jifen{margin: 0 0 0 10px;color: #fd8838;}
	      .keyong{float: right;margin: 15px 4% ;color: #bdbdbd;font-size: 13.33px;}
	.new_popup-menu-row{
		width: 100%;
		text-align: left;
		background-color: #fff;
		padding: 5px;
	}
.new_popup-menu-row img {
    display: inline-block;
    width: 23px;
    height: 23px;
    margin-left: 20px;
    vertical-align: middle;
}
.newzhifup{font-size: 12px;color: #c1c1c1;}
.newdiv{
	font-size: 15px;
    margin-left: 15px;
    display: inline-block;
    vertical-align: middle;
    color: #1c1f20;
    max-width: 76%;
}
.popup-menu-title{border-bottom: 1px solid #ddd;margin: : 0 4px;overflow: hidden;position: fixed;left: 0;width: 100%;z-index: 2902;}
.zhifuthree{position: fixed;z-index: 2901;bottom:0;left: 0;width: 100%;height: 351px;background-color: #ffffff;}
.pmoth{color: #707070;font-size: 11px;text-align: center;padding-top: 8px;}
.imgnoth{width: 14px;height: 14px;display: block;margin: 3px auto 0 auto;}
.zhifuthimg{width: 14px;height: 14px;float: left;margin: 5px 0 0 15px;}
.chakanmoveth{position: fixed;bottom: 0;left: 0;height: 50px;z-index: 2902;background-color: #ffffff;width: 100%;}
.scrolly{overflow-y: scroll;}
#new_zhifuPannel{margin: 46px 0 50px 0;height: 100%;}
.delivery-time-action{
	width: auto !important;
	margin-right: 5px;
}
.delivery-time-action span{
	border: 1px #C1C0C0 solid;
    border-radius: 5px;
    padding: 3px;
	font-size: 12px;
}
.dlvb{
	z-index: 10001;
    background-color: #fff;
    position: fixed;
    top: 25%;
    left: 15%;
    width: 70%;
    border-radius: 3px;
}
.dlvb-title{
	text-align: center;
    padding: 7px 0;
    font-size: 18px;
	color: #31b6e7;
	border-bottom: 2px solid #31b6e7;
}
.dlvb-content-box{
	min-height: 100px;
}
.dlvb-btn{
	border-top: 1px solid #dbdbdb;
    height: 36px;
    line-height: 36px;
    padding: 0;
    margin: 0;
    font-weight: normal;
    text-shadow: none;
    -webkit-border-radius: 0;
    -webkit-box-shadow: none;
    cursor: pointer;
    overflow: hidden;
    font-size: 14px;
}
.dlvb-confirm{
	border-right: 1px solid #dbdbdb;
    display: inline-block;
    width: 49%;
    position: relative;
    z-index: 5;
    text-align: center;
    color: #000;
}
.dlvb-cancel{
    display: inline-block;
    width: 49%;
    position: relative;
    z-index: 5;
    text-align: center;
    color: #000;
}
.dlvb-content{
	text-align: center;
}
.dlvb-content span{
    display: inline-block;
    margin: 8px;
    height: 30px;
    font-size: 14px;
    width: 170px;
    line-height: 25px;
    border-radius: 11px;
    border: 2px #ccc solid;
}
.dlvb-selected span{
	display: inline-block;
    margin: 8px;
    height: 30px;
    font-size: 14px;
    width: 170px;
    line-height: 25px;
    border-radius: 11px;
    border: 2px #31b6e7 solid;
    color: #31b6e7;
}
.sharebg {
    background-color: rgba(0, 0, 0, 0.4);
    bottom: 0;
    height: 100%;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    width: 100%;
    z-index: 2000;

}
.collage_explain{
	position: absolute;
    top: 58px;
    border: 1px #ccc solid;
    padding: 2px 3px;
    color: #ff8430;
	right: 3px;
}
.hide{display:none;}
.det{width: 100%;padding: 10px 2.5%;background-color: #fff;/*margin-top: 15px;border-top: 1px solid #d1d1d1;border-bottom: 1px solid #d1d1d1;*/font-size: 15px;position: relative;}
.det img{max-width: 100%;}
.det .exp{font-size: 17px;color: #2a2a2a;}
.det .icon{width: 20px;height: 20px; background-color: #cccccc;color: #fff;border-radius: 50%;transform: rotate(180deg);-webkit-transform: rotate(180deg);text-align: center;display: inline-block;margin-left: 10px;}
.det .icon span{line-height: 20px;height: 20px;}
.det .detBtn{float: right;margin-top: 3px;width: 20px;}
.det .detBottom{color: #666666;width: 100%;margin-top: 15px;/*font-size: 0;*/}
.cell_icon {
    position: absolute;
    overflow: hidden;
    left: 13px;
    top:8px;
    background-image: url(./collageActivities/img/cell_icon.png);
    display: block;
    width: 40px;
    height: 20px!important;
    background-repeat: no-repeat;
    background-size: 40px 20px;
    font-size: 1rem!important;
    color: #fff!important;
    line-height: 18px!important;
    text-align: center;box-sizing:border-box;padding:0 2px;
}
	.tips-list{font-size:0;margin:1px 0 0 0;}
	.tips-list .bg-red{background-color:red;}
	.tips-list .tips{display:inline-block;width:14px;height:14px;font-size:10px;line-height:14px;text-align:center;color:#fff;margin:0 3px 0 0;}

	.full-shop{background-color:#fff;padding:15px 10px;display:flex;justify-content:space-between;align-items:center;}
	.full-shop .num{font-size:14px;color:#f4212b;}
	.full-shop .num img{height:20px;margin:0 8px 0 0;}
	.full-shop .nub{font-size:13px;color:#d1d1d1;flex-grow:1;text-align:right;margin:0 10px 0 0;}
	/*积分类型*/
	.jifen-type-alert{position: fixed;left: 0;bottom: 0;width: 100%;
		background-color: #fff;box-sizing: border-box;height: 200px;z-index: 2999;display: none;}
	.jifen-type-alert .jifen-title{width: 100%;font-size: 15px;
    padding-left: 15px;color: #1c1f20;box-sizing: border-box;    height: 45px;
    line-height: 45px;
}
.jifen-type-alert .jifen-content{width: 100%;font-size: 15px;
    padding-left: 15px;padding-right: 15px;color: #1c1f20;box-sizing: border-box;    height: 45px;
    line-height: 45px;display: flex;justify-content: space-between;align-items: center;
}
.jifen-type-alert .jifen-content .select-box{width: 20px;height: 20px;
border:1px solid #eee;background-size: 100% 100%;background-repeat: no-repeat; }
.jifen-type-alert .jifen-content .select-box.add-gou{background-image: url(./images/gou.png);
}
.jifen-type-alert .jifen-btn-box{height: 50px;line-height: 50px;display: flex;justify-content: space-between;align-items: center;font-size: 0;border-top: 1px solid #eee;position: fixed;left: 0;bottom: 0;width: 100%;}
.jifen-type-alert .jifen-btn-box .cancle-btn,
.jifen-type-alert .jifen-btn-box .sure-btn
{height: 50px;line-height: 50px;text-align: center;font-size: 15px;width: 50%;}
.select_store_span_r{max-width: 40%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;}
</style>
 <script>
<?php echo 'var order_debug = true ;'		//调试开关?>
<?php echo 'var buy_all_data_json='.$buy_all_data_json.';' ;?>

<?php echo 'if(order_debug){console.log(buy_all_data_json);}' ;?>
<?php echo 'var buy_array_json='.$buy_array_add_express_json.';';?>

<?php echo 'var curr_arr_json='.json_encode($curr_arr).';';?>
<?php echo 'console.log(curr_arr_json);';?>


<?php echo 'if(order_debug){console.log(buy_array_json);}'?>
<?php echo 'var supply_express_json='.$supply_express_json.';';?>
<?php echo 'if(order_debug){console.log(supply_express_json);}'?>
 </script>
<?php require_once('../common/input_password.php');?>

<body data-ctrl=true >
	<div id="gyuji" style="position:fixed;top:0;z-index:2900;left:0;background:#000000;opacity:0.5;width:100%;height:100%;display:none;"></div>
    <div class="am-share" id="pass_w" style="width:100%;position: fixed;top:50px;z-index: 3000;display:none;height:201px">
        <div class="box">
        	<span class="guanbicha">X</span>
            <h1>输入支付密码</h1>
            <label for="ipt">
                <ul id="p_pwd" pay_type="card">
                    <li></li>
                    <li></li>
                    <li></li>
                    <li></li>
                    <li></li>
                    <li></li>
                </ul>
            </label>
            <input type="text" id="ipt" maxlength="6">
        <!--     <div style="width:100%;text-align: right;padding:10px;"> <a onclick='xiugai_pass();'>密码管理</a></div>
            <a class="commtBtn" onclick="commitBtn();" style="display:none;">确认</a> -->
        </div>
    </div>
	<!-- header -->
	<!-- <header data-am-widget="header" class="am-header am-header-default header">
		<div class="am-header-left am-header-nav header-btn">
			<img class="am-header-icon-custom" src="./images/center/nav_bar_back.png"/><span>返回</span>
		</div>
	    <h1 class="header-title">确认订单</h1>
	</header>
    <div class="topDiv" style="height:49px;"></div> -->   <!-- 暂时屏蔽头部 -->
	<!-- header -->

    <!-- 个人地址 -->
	<?php
	//$add_keyid = 1;
	if( $is_virtual != 1 ){	//虚拟产品不需要收货地址
		if($add_keyid<0){		//开始判断是否为空

			echo "	<script>
						var is_virtual = ".$is_virtual.";
						window.onload = function(){
							showConfirmMsg('提醒','是否马上添加收货地址呢？','确定','取消',function(){
								window.location.href = 'my_address.php?customer_id=".$customer_id_en."&a_type=1';
							});
						}
					</script>";

	?>

		<div class = "content-header" id="content_location">
			<div class = "content-header-left1">

				<div class = "content-header-left1-top2" style="margin-top: 8px;">

					<span style = "" onclick="location.href='my_address.php?customer_id=<?php echo $customer_id_en?>&a_type=1';"> 还没有团长收货地址</span>
				</div>
			</div>
			<div class = "content-header-right">
				<img src = "./images/vic/right_arrow.png" width = "10" height = "20">
			</div>
			<div style="clear:both"></div>
		</div>
		<div  class = "content-space"></div>
	<?php
		}else{
	?>
		<div class = "content-header">
			<div class = "content-header-left1">
				<div class = "content-header-left1-top1">
					<span class = "font1"> 团长姓名:<?php echo $add_name?></span><span class = "font2">团长电话:<?php echo $add_phone?> </span>
				</div>
				<div class = "content-header-left1-top2">
					<span style = "" > 门店地址:<?php echo $address_str;?></span>
				</div>
				<div class = "content-header-left1-top2">
					<span style = "" > 详细地址:<?php echo $detail_address;?></span>
				</div>				
			</div>
			<div class = "content-header-right" >
				<img src = "./images/vic/right_arrow.png" width = "10" height = "20">
			</div>
			<div style="clear:both"></div>
		</div>
		<div  class = "content-space"></div>
	<?php }
	}
	?>
	<!--个人信息-->
        <?php
        //<+ 韦 14:41 2016/9/3 我不知道这里为什么没有定义，先这样检测如果为null，定义一个空值先。
        if(!isset($is_virtual)){
            $is_virtual = '';
        }
        //+> 韦 14:41 2016/9/3
        ?>
	<span class="icon-default" id="information" data-id="<?php echo $add_keyid;?>" data-name="<?php echo $add_name;?>" data-phone="<?php echo $add_phone;?>" data-address="<?php echo $address;?>" data-location_p="<?php echo $location_p;?>" data-location_c="<?php echo $location_c;?>" data-location_a="<?php echo $location_a;?>" data-identity="<?php echo $identity;?>" data-identityimgt="<?php echo $identityimgt;?>" data-identityimgf="<?php echo $identityimgf;?>" data-is_virtual="<?php echo $is_virtual;?>"></span>
	<!--个人信息-->


	<!-- 个人地址 -->
    <?php
        require_once($_SERVER['DOCUMENT_ROOT'].'/mshop/admin/model/exchange.php');
        $exchange_m = new model_exchange($customer_id);
        $platform_price_no_exchange = $platform_price - $total_exchange_price;
        $exchange_activities = $exchange_m->get_order_exchange_activities($platform_price_no_exchange,1);
        if( $exchange_activities ) {
            foreach ($exchange_activities as $key => $value) {
                if( $value['exchange_num'] > $count_ex || $value['exchange_num'] == -1 ){
                    $count_ex = $value['exchange_num'];
                }
            }
            $count_ex_str = $exchange_activities[0]['exchange_num']==-1 ? '可换购件数不限制' : '可换购' . $exchange_activities[0]['exchange_num'] . '件';
    ?>
        <div class="full-shop" onclick="exchange()">
            <div class="num"><img src="images/icon-full-shop.png"/>
                满
                <?php if(OOF_P != 2) echo OOF_S ?>
                <ex id='exchange_threshold'>
                <?php echo $exchange_activities[0]['threshold']?>
                </ex>
                <?php if(OOF_P == 2) echo OOF_S ?>
                换购
            </div>
            <div class="nub"><?php echo $count_ex_str ?></div>
            <img src="./images/vic/right_arrow.png" width="10" height="20">
        </div>
    <?php } ?>
	<!--产品信息-->
	<div>
	<ul id="resultData" class = "content-list">
	<?php

			  $all_rcount = 0;					//产品的数量

			  $all_price = 0;					//产品的价格
			  //+ 韦 14:41 2016/9/3
                          $all_express = 0;
                          //+ 韦 14:41 2016/9/3
                          $all_pro_weight = 0;

			  $ii = 0;							//供应商定位

			  $sum_all_money = 0;				//订单总价

			  $sum_p_is_identity = 0;			//累计产品需要身份证

			  $sum_all_supply_pros_need_score = 0;	//累计产品需要的积分

			  $sum_need_integral = 0;				//累计兑换产品需要的商城积分
			  $sum_need_store_integral = 0;			//累计兑换产品需要的兑换积分


			  $sum_self_reward = 0;	//累计3级分佣
			  $sum_shop_reward = 0;	//累计店铺分佣


			  $allpid_str = '';	//将所有pid拼接成字符串
			  $pidcount_str = '';	//将所有产品的数量拼接成字符串

			 //var_dump($buy_all_data);

	foreach($buy_all_data as $supply_id_arr => $val){

			 $arr_data = $val;				//每个供应商所有的产品信息

			 $sum_rcount = 0;				//累计产品数目

			 $sum_price = 0;				//累计产品总价

			 $sum_is_invoice = 0;			//累计开启发票数目

			 $sum_is_express = 0;			//累计配送方式

			 $sum_is_virtual = 0;			//累计虚拟产品

			 $sum_express = 0;				//累计快递费



			 $sum_pro_weight = 0; 			//累计重量

			 $sum_is_Pinformation = 0;		//累计必填信息开关之和，大于0则显示



			 $price_express = 0;		  	//同一个供应商的产品金额+快递

			 $PID_pros = '';			 	//同一个供应商的产品属性拼接

			 $PID_str = '';			 		//同一个供应商的产品ID拼接

			 $currentpid_str = '';
			$supply_revenue = array();		//供应商税收数组
			$temp_revenue = array();

			 $shop_name 		= $arr_data [0]['supply']['shop_name'];			//店铺名
			 $isbrand_supply 	= $arr_data [0]['supply']['isbrand_supply'];	//是否品牌供应商
			 $brand_logo 		= $arr_data [0]['supply']['brand_logo'];		//品牌供应商logo
			 $default_shop_logo = './images/goods_image/iconfont-jiantou.png';	//默认店铺logo

			 /*行邮税 start*/
			$tax_money = 0;
			$tax_money 	= $arr_data['tax'][1];
			$tax_code 	= $arr_data['tax'][2];
			$tax_msg 	= $arr_data['tax'][3];

			$tis = '';
			if($sum_is_express == 0 ){  //0表示都有配送
				if($tax_code >20000){		//错误提示
					$tis  = $tax_msg;
				}elseif($tax_code == 10008){
					$tis  = $tax_money.'<?php echo OOF_T ?>';
				}
			}else{
				$tis  = '无配送方式，导致税收计算失败';
			}
			/*行邮税 end*/
			//获取订货系统的门店名
			if(!empty($o_shop_id) && $o_shop_id > 0 && $is_orderingretail_store){
				$query = 'SELECT shop_name FROM orderingretail_shop where id ='.$o_shop_id;
				$result = _mysql_query($query) or die('Query failed table orderingretail_shop: ' . mysql_error());
				while ($row = mysql_fetch_object($result)) {
	   				$shop_name = $row->shop_name;
	   				break;
				}
			}
	?>



		<li class="itemWrapper"  supply_id="<?php echo $supply_id_arr;?>" style="margin-top:0"  ii=<?php echo $ii ;?> tax_code='<?php echo $tax_code;?>' tax_msg='<?php echo $tax_msg;?>'>
			<!-- 店铺名 -->
			<div class="item-row1">
				<div class="item-row1-left1">

					<img src="<?php if($brand_logo==''){echo $default_shop_logo;}else{echo $brand_logo;}?>" width="20" height="20" class="logo-img">
				</div>
                <div class="item-row1-left2"><span><?php echo $shop_name;?></span></div>

			</div>
			<!-- 店铺名 -->

			<!--判断是否有下架或过期的商品-->
            <?php

                $product_isnone = 0;
                foreach($arr_data as $k=>$v){
                    if($arr_data[$k]['pid'] != '') {
                        $products_pid = $arr_data[$k]['pid'];
                        $sql_product_isout = "select name from weixin_commonshop_products where isvalid = true and isout = 0 and id ='" . $products_pid . "'";
                        $res_product_isout = _mysql_query($sql_product_isout) or die("sql_product_isout query error : " . mysql_error());
                        if (!($row_product_isout = mysql_fetch_object($res_product_isout))) {
                            $product_isnone = 1;
                        }
                    }
                }

            ?>

			<?php
                    $supply_pid_str     = '';   //供应商订单产品id字符串
                    $supply_pros_str    = '';   //供应商订单产品属性字符串
                    foreach($arr_data as $key => $buy_values){
					//同一个供应商的每个产品遍历
                                                        //<- 韦 14:41 2016/9/3 有错误警告
                                                        //if($buy_values[0] == 'no_use'){			//供应商邮费信息不能显示
                                                        //    continue;
                                                        //}
                                                        //-> 韦 14:41 2016/9/3
                                                        //<+ 韦 14:41 2016/9/3 检测如果$buy_values[0]不为空的时候才能没有警告错误

                                                        if(!empty($buy_values[0]) && ($buy_values[0] == 'no_use')){ //供应商邮费信息,行邮税不能显示
                                                            continue;
                                                        }
							//+> 韦 14:41 2016/9/3
							//- 韦 14:41 2016/9/3
							//$select_express_id = $buy_values['express']['select_express_id'];		//获取快递规则ID
                                                        //<+ 韦 14:41 2016/9/3
                                                        $select_express_id = 0;
                                                        if(!empty($buy_values['express']['is_express'])){
                                                            $select_express_id = $buy_values['express']['select_express_id'];		//获取快递规则ID
                                                        }
                                                        //+> 韦 14:41 2016/9/3
							/*$is_express = 0;		//是否有配送方式
							if(!empty($buy_values['express']['is_express'])){
								$is_express = $buy_values['express']['is_express'];
							}*/
							//是否有配送方式 -1无，0有
							if($supply_express[$supply_id_arr][0] == 'failed'){
								$is_express = -1;
							}else{
								$is_express = 0;
							}

							$is_virtual = 0;		//是否虚拟产品
							if(!empty($buy_values['is_virtual'])){
								$is_virtual = $buy_values['is_virtual'];

							}


                            $supply_pid_str     .= $buy_values['pid'].',';
                            $supply_pros_str    .= $buy_values['prvalues'].',';
							$allpid_str         .= $buy_values['pid'].',';
							$pidcount_str       .= $buy_values['rcount'].',';


							$currentpid_str .= $buy_values['pid'].',';


			?>
			<?php
				$is_express_arr[] =$is_express;
				$buy_pid_arr[]    = $buy_values['pid'];
			?>
			<!--产品详情-->
			<div class="product" id="pid_<?php echo $buy_values['pid'];?>" pid="<?php echo $buy_values['pid'];?>">


			<div class="itemMainDiv" select_express_id='<?php echo $select_express_id ;?>' pro_name = '<?php echo $buy_values['name'] ;?>' is_express='<?php echo $is_express ;?>' save_is_express='<?php echo $is_express ;?>' is_virtual='<?php echo $is_virtual ;?>' pros_need_score='<?php echo $buy_values['pros_need_score'];?>'>
					<?php
						$explain = '';
						$type_img = '';
						if( $is_collage_product && $group_buy_type == 2 ){
							$query_activity = "SELECT type FROM collage_activities_t WHERE id=".$activitie_id;
							$result_activity = _mysql_query($query_activity) or die('Query_activity failed:'.mysql_error());
							$activity_type = mysql_fetch_assoc($result_activity)['type'];

                            $query_activity1 = "SELECT type_name FROM collage_activities_explain_t WHERE customer_id=".$customer_id." and type=".$activity_type;
							$result_activity1 = _mysql_query($query_activity1) or die('Query_activity1 failed:'.mysql_error());
							$type_str = mysql_fetch_assoc($result_activity1)['type_name'];
							//获取团说明
							switch( $activity_type ){
								case 1:
									//$type_str = '普通团';
									$type_img = './collageActivities/img/icon17.png';
								break;
								case 2:
									//$type_str = '抽奖团';
									$type_img = './collageActivities/img/icon15.png';
								break;
								case 3:
									//$type_str = '秒杀团';
									$type_img = './collageActivities/img/icon14.png';
								break;
								case 4:
									//$type_str = '超级团';
									$type_img = './collageActivities/img/icon16.png';
								break;
								case 5:
									//$type_str = '抱抱团';
									$type_img = './collageActivities/img/icon17.png';
								break;
								case 6:
									//$type_str = '免单团';
									$type_img = './collageActivities/img/icon17.png';
								break;
							}
							$explain = '';
							$get_explain = $collageActivities->getExplain($customer_id)['content'];
							foreach( $get_explain as $k => $v ){
								if( $v['type'] == $activity_type ){
									$explain = $get_explain[$k];
									break;
								}
							}
						}
						if( !empty($type_img) ) {
					?>
					<!-- <img style="position: absolute;width: 38px;left: 13px;top: 8px;" src="<?php echo $type_img;?>"> -->
					<span class="cell_icon"><?php echo $type_str;?></span>
					<?php } ?>
				<!--产品图片-->
				<div class="itemPhoto" style="background-image:url(<?php
                    if(empty($buy_values['imgurl'])){
                        $query6 = "select imgurl from weixin_commonshop_product_imgs where isvalid=true and customer_id=".$customer_id." and product_id=".$buy_values['pid']." limit 1";

                        $result6 = _mysql_query($query6) or die('query failed6'.mysql_error());
                        while($row6 = mysql_fetch_object($result6)){
                            $product_default_imgurl = $row6->imgurl;	//商品封面图
                        }
                        echo $product_default_imgurl;
                    }else{
                        echo $buy_values['imgurl'];
                    }
                ?>)"></div>
				<!--产品属性-->
				<div class="contentLiDiv">
					<div class="itemProName">
					<?php

                                        //- 韦 14:41 2016/9/3
					//if($buy_values['supply']['brand_name']!= NULL){						//获取供应商的LOGO
                                        //+ 韦 14:41 2016/9/3
                                        if(!empty($buy_values['supply']['brand_name']) && ($buy_values['supply']['brand_name']!= NULL)){						//获取供应商的LOGO
						echo '['.$buy_values['supply']['brand_name'].']' ;

					}
                                        ?>
					<?php echo $buy_values['name'];										//输出产品名称		?>
					</div>
					<div class="itemProContent">

                        <?php
                            //输出产品的属性
                            foreach($buy_values['pros'] as $k => $value){
                                echo $value['pro_parent_name'].':'.$value['child_name'];
                        ?>
                        <?php } ?>

					</div>
					<?php
                        if( $buy_values['exchange'] == 1 ){
                            echo '<p class="tips-list"><span class="tips bg-red">赠</span></p>';
                        }
					?>
				<?php
					if ( !empty($delivery_time) ) {
				?>
					<div style="font-size:12px;color:#c1c1c1;">
						<?php echo str_replace('至', '-', $delivery_time);?>
					</div>
					<?php } ?>

					<!-- <div class="itemProContent">
						<?php echo '积分：'.$buy_values['pros_need_score'] ;?>			//输出积分
					</div -->

					<!--积分管理-->
					<?php
						if( $buy_values['integral_p'] > 0){
					?>
						<div class="itemProContent choose_shop_integral" <?php if($using_exchange_type == 1 || $buy_values['integral_p'] == 0) echo "style='display:none;'"?>>
							<?php echo $shop_int_name.'：'.$buy_values['integral_p'].'+￥'.$buy_values['money_p'] ;?>
						</div>
					<?php
						}
						if( $buy_values['store_integral_p'] > 0 ){
					?>
						<div class="itemProContent choose_store_integral" <?php if($using_exchange_type == 0 || $buy_values['store_integral_p'] == 0) echo "style='display:none;'"?>>
							<?php echo $store_int_name.'：'.$buy_values['store_integral_p'].'+￥'.$buy_values['money_p'] ;?>
						</div>
					<?php
						}
					?>


					<!--积分管理-->

					<!--产品行邮税-->
					<?php if($buy_values['tax_type'] >1 ){?>
					<div class="itemProContent">
						 <div class="tax" code="10008">
						 <button class="btn-shui"><div class="test5">
							<span>税</span></div>
							<div style="display:inline-block;padding-right:3px;"><?php echo $buy_values['tax_name'];?> </div>
						 </button>
						 <span style="font-size:12px;"></span>
						 </div>
					</div>
					<?php } ?>
					<!--产品行邮税-->
				</div>
				<!--产品属性-->
				<!--产品价格-->
				<div class="rightWrapper">
					<div class="itemProPrice">
					<?php if(OOF_P != 2) echo OOF_S ?>
                    <?php echo number_format($buy_values['now_price'],2);?>
					<?php if(OOF_P == 2) echo OOF_S ?>
					</div>
					<div class="itemProCount">x<?php echo $buy_values['rcount'];?></div>

				</div>
				<?php
						if( !empty($explain) ){
					?>
					<div class="collage_explain"><?php echo $explain['title'];?></div>
					<?php
						}
					?>
				<!--产品价格-->
			</div>

			</div>
			<!--产品详情-->

			<?php


					/********统计每个供应商的所有产品的数据 start********/

					//累计产品数目
					 $sum_rcount += $buy_values['rcount'];
					 //累计产品总价
					 $sum_price += $buy_values['totalprice'];

					 //累计开启发票
					 $sum_is_invoice += $buy_values['is_invoice'];	//只要大于0就能开启发票

					 //累计是否有无配送方式


					// $sum_is_express += $is_express;

					  //累计是否虚拟产品

					 $sum_is_virtual += $is_virtual;


					 //累计产品总量

                                         //- 韦 14:41 2016/9/3
					  //$sum_pro_weight += $buy_values['express']['weight'];
					 //+ 韦 14:41 2016/9/3
                                          if(!empty($buy_values['express']['weight'])){
                                              $sum_pro_weight += $buy_values['express']['weight'];
                                          }

					//累计必填信息开关
					$sum_is_Pinformation += $buy_values['is_Pinformation'];
					if($buy_values['is_Pinformation'] ==1){
						$PID_str .= $buy_values['pid'].',';
						$PID_pros .= $buy_values['prvalues'].'|*|';
					}


					//累计是否需要身份证
					 $sum_p_is_identity += $buy_values['p_is_identity'];

					//累计产品需要积分
					 $sum_all_supply_pros_need_score +=  $buy_values['pros_need_score']*$buy_values['rcount'];

					 //累计兑换产品需要积分
					 $sum_need_integral 	  += $buy_values['integral_t'];			//商城
					 $sum_need_store_integral += $buy_values['store_integral_t'];	//兑换
					 /********统计每个供应商的所有产品的数据 end********/


			}



					//总金额 = 产品总价+每个供应商的快递费 +税收
					$sum_express = $arr_data['supply_express'][1];	//每个供应商的总运费 + 税收
					if(empty($sum_express)){
						$sum_express = 0;
					}
					$price_express = $sum_price + $sum_express ;
					//var_dump($sum_express);

					/*行邮税 start*/

					$price_express += $tax_money;						//税收合计到供应商总价

					/*行邮税 end*/

					//var_dump($arr_data['self_reward']); 

					$sum_self_reward +=  !empty($arr_data['self_reward']['Dreward'])?$arr_data['self_reward']['Dreward']:0 ;

					$sum_shop_reward +=  !empty($arr_data['self_reward']['user_shareholder_reward'])?$arr_data['self_reward']['user_shareholder_reward']:0 ;

                    if( $arr_data[0]['is_supply_id'] == -1 ){
                        $platform_self_reward +=  !empty($arr_data['self_reward']['Dreward'])?$arr_data['self_reward']['Dreward']:0 ;
                        $platform_shop_reward +=  !empty($arr_data['self_reward']['user_shareholder_reward'])?$arr_data['self_reward']['user_shareholder_reward']:0 ;
                    }
					//var_dump($sum_self_reward);
                    //zhou
                   	//可抵扣金额减去复购金额
                   	$curr_arr[$supply_id_arr] = $curr_arr[$supply_id_arr]-$sum_self_reward-$sum_shop_reward;
                   	if($curr_arr[$supply_id_arr] < 0)
                   	{
                   		$curr_arr[$supply_id_arr] = 0;
                   	}
                   	$sum_self_newreward       = $sum_self_reward+$sum_shop_reward;
                   	//$sum_self_newreward       = 0;

			?>


			<script type="text/javascript">
				//可使用的购物币
				var currency_newmoney  = <?php echo $curr_arr[$supply_id_arr] ?>;
				var sum_self_newreward = <?php echo $sum_self_newreward ?>;   
			</script>
			<div class="white-list">
				<?php
					if( $is_collage_product && $group_buy_type == 2 && !empty($explain) ){
				?>
				<div class="list-one explain">
					<div class="det">
						<span class="exp"><?php echo $explain['title'];?></span><div class="icon"><span>!</span></div>
						<img class="detBtn" src="images/collage_activity/xiangshang_icon.png">
						<div class="detBottom">
							<div class="detCell"><?php echo $explain['content'];?></div>
						</div>
					</div>
				</div>
				<div class="line"></div>
				<?php
					}
					if( $sendstyle_express ){
				?>
				<!--配送方式-->
<!--				<div class="list-one express-type button buttonclick send_way" <?php if ($is_orderingretail_store) { ?>onclick="choose_send_way(this);"<?php } ?> supply_id="<?php echo $supply_id_arr;?>"  pid="<?php echo substr($PID_str,0,-1);?>" ii=<?php echo $ii ;?> supply_express="<?php echo $supply_express[$supply_id_arr][0];?>" sum_express="<?php echo $sum_express;?>" supply_pid_str="<?php echo trim($supply_pid_str, ',');?>" pidcount_str="<?php echo trim($pidcount_str, ',');?>" supply_pros_str="<?php echo trim($supply_pros_str, ',');?>" shop_id="<?php echo $o_shop_id;?>">
				   <div class="left-title">
					   <span>配送方式:</span>
				   </div>

				   <div class="center-content" style="width: 58%">
					   <span><span>
					   <?php


					   if($supply_express[$supply_id_arr][0] == 'failed'){
						   echo '无配送方式';		//不允许支付
					   }else{
						   if($sum_express>0){

								$msg = '快递';
								if( OOF_P != 2 ){
									$msg .= OOF_S;
								}
								$msg .= $sum_express;
								if( OOF_P == 2 ){
									$msg .= OOF_S;
								}
								echo $msg;
							}else{
								echo '免邮';
							}
					   }


					  ?>
					   </span></span>
				   </div>
   				    <div class="right-action">
					   <img src="./images/vic/right_arrow.png" width="10" height="20">
				    </div>
				</div>


				<div class="line"></div>
-->				
				<!--配送方式-->
				<?php } ?>

				<?php if( $arr_data[0]['tax_type'] > 1 ){?>
				<!--行邮税-->
				<div class="list-one express-type">
				   <div class="left-title">
					   <span><?php echo $arr_data[0]['tax_name']?>税:</span>
				   </div>
				   <div class="center-content">
					   <span><span>
					   <?php
					   echo $tis;
					  ?>
					   </span></span>
				   </div>

				</div>


				<div class="line"></div>
				<!--行邮税-->
				<?php } ?>

                <!--订货系统门店-->
                <?php
                    if ($is_orderingretail_store)
                    {
                ?>
                    <div class="list-one orderingretail_store button buttonclick mendian" supply_id="<?php echo $supply_id_arr;?>"  pid="<?php echo substr($PID_str,0,-1);?>" pros="<?php echo substr($PID_pros,0,-3);?>" ii=<?php echo $ii ;?> supply_pid_str="<?php echo trim($supply_pid_str, ',');?>" pidcount_str="<?php echo trim($pidcount_str, ',');?>" supply_pros_str="<?php echo trim($supply_pros_str, ',');?>" onclick="go_to_orderingretail_store(this)">
					<div class="left-title">
                        <span>选择门店自提/快递</span>
                        <span class="select_store_span_r"><?php if (!empty($o_shop_id) && $o_shop_id > 0) echo $shop_name;?></span>
				    </div>
                    <?php if (empty($o_shop_id) || $o_shop_id < 0) { ?>
				    <div class="right-action">
					   <img src="./images/vic/right_arrow.png" width="10" height="20">
				    </div>
                    <?php } ?>
				</div>
				<div class="line"></div>
                <?php
                    if (!empty($o_shop_id) && $o_shop_id > 0)
                    {

                ?>
                <script>
                    var orderingretail_store_object = localStorage.getItem('orderingretail_store_<?php echo $user_id;?>'); 	//读取localStorage的数据
                    var orderingretail_store_object_arr = new Array();
                    orderingretail_store_object_arr = JSON.parse(orderingretail_store_object);
                    if (orderingretail_store_object_arr==null)
                    {
                        var _A = new Array();
                        var rtn_array_temp = new Array('<?php echo $supply_id_arr ? $supply_id_arr : -1;?>','<?php echo $o_shop_id;?>','<?php echo $o_branch_id;?>','<?php echo $shop_name;?>',1);
                        _A[<?php echo $ii ;?>] = rtn_array_temp ;
                        var rtn_array_json = JSON.stringify(_A);				//转JSON
                        localStorage.setItem('orderingretail_store_<?php echo $user_id;?>',rtn_array_json);	//存入localStorage
                    }
                </script>
                <?php
                    }
                ?>
                <!--订货系统门店-->
                <?php
                    } elseif ( $sendstyle_pickup ){
                ?>
				<!--门店-->
<!--				<div class="list-one store button buttonclick mendian" supply_id="<?php echo $supply_id_arr;?>"  pid="<?php echo substr($PID_str,0,-1);?>" pros="<?php echo substr($PID_pros,0,-3);?>" ii=<?php echo $ii ;?> <?php if($is_collage_product && $group_buy_type == 2){echo "style='display:none;'";}?>>
					<div class="left-title">

					   <span>选择门店自提</span>
						<span class="select_store_span_r">							</span>
				    </div>
				    <div class="right-action">
					   <img src="./images/vic/right_arrow.png" width="10" height="20">
				    </div>
				</div>
				<div class="line" <?php if($is_collage_product && $group_buy_type == 2){echo "style='display:none;'";}?>></div>
-->				
				<!--门店-->
				<?php } ?>

				<!--优惠券-->				
				<?php
					$coupon_count = 0;
					$query_is_coupon="select is_coupon from weixin_commonshops where isvalid=true and customer_id=".$customer_id." limit 0,1";
					$is_coupon=0; //是否开启优惠券
					$result_is_coupon = _mysql_query($query_is_coupon) or die('W3667 Query failed: ' . mysql_error());
					while ($row_is_coupon = mysql_fetch_object($result_is_coupon)) {
						$is_coupon = $row_is_coupon->is_coupon;
						break;
					}
					if($is_coupon>0){
						$pidArr = substr($currentpid_str,0,strlen($currentpid_str)-1);
						$arr = explode(',',$pidArr);
						$str = '';
						foreach ($arr as $k => $v) {
							$str .= " c.connected_id LIKE '%".$v."%' or ";
						}
						$str = substr($str,0,strlen($str)-3);

						$query = "SELECT count(1) as coupon_count FROM weixin_commonshop_couponusers u inner join weixin_commonshop_coupons c on u.coupon_id=c.id WHERE u.user_id=".$user_id." AND u.customer_id=".$customer_id." AND u.isvalid=true AND u.type=1 AND u.is_used=0 AND (c.user_scene=0 or (c.user_scene=1 and (".$str."))) and u.is_receive=true";

						//使用中的优惠券不为空
						if(!empty($usingStr)){
							$query .= " AND u.id not in (".$usingStr.")";
						}
						$query .= " AND u.startline <='".date("Y")."-".date("m")."-".date("d")." ".date("H").":".date("i").":".date("s")."' AND u.deadline >='".date("Y")."-".date("m")."-".date("d")." ".date("H").":".date("i").":".date("s")."' ";
						if( $is_collage_product && $group_buy_type == 2 && $group_id < 0 ){
                            if(!$coupon_onoff){
                                $query .= " AND u.class_type=3";
                            }							
						} else {
							$query .= " AND u.class_type!=3";
						}
                        //保存优惠券日志记录，追溯个别用户无法使用问题    我注释掉了，要记录请规范写法 zhaojing
		                 /*file_put_contents("log_youhuiquan.txt", date("Y-m-d H:i:s").",query=======".$query."\r\n",FILE_APPEND); */
						$result=_mysql_query($query)or die('Query failed111'.mysql_error());
						while($row=mysql_fetch_object($result)){
							$coupon_count = $row->coupon_count;
						}
					}
			   ?>
               <!-- 参团&&开关关闭 || 团长免单团(团长) ||积分兑换 不能用优惠券 -->

					<div class="list-one coupon button buttonclic" supply_id="<?php echo $supply_id_arr;?>"  pid="<?php echo substr($PID_str,0,-1);?>" pros="<?php echo substr($PID_pros,0,-3);?>" ii=<?php echo $ii ;?> <?php if(($is_collage_product && $group_buy_type == 2 && $group_id > 0 && $coupon_onoff==0)||($is_collage_product && $collage_type == 6 && $group_id < 0) ||($sum_need_integral  >0 || $sum_need_store_integral  >0)){echo "style='display:none;'";}?>>
						<div class="left-title">
						   <span>优惠券：</span>
							<span class="select_coupon_span_r" style="color: #fff !important;background-color:#FF0001;padding: 0 10px;"><?php echo $coupon_count;?>张可用</span>
						</div>
						<div class="right-action">
						   <img src="./images/vic/right_arrow.png" width="10" height="20">
						</div>
					</div>
					<div class="line" <?php if($is_collage_product && $group_buy_type == 2 && $group_id > 0){echo "style='display:none;'";}?>></div>
			
				<!--优惠券-->

            <?php
            if($isOpenCurrency == 1 || ($if_bbt==1 && $join_bbt_times>0) || ($if_bbt==1 && $join_bbt_times==0 && $if_bbt_curr_use == 1) || ($if_bbt==0 && $shopcode_onoff==1)){
            ?>
            <!--购物币-->
            <div class="itembutton"
            <?php
            	if($sum_need_integral  > 0 || $sum_need_store_integral  >0){ //兑换积分不能用购物币
            		echo "style='display:none;'";
            	}else{
	                if($if_bbt==0){//普通拼团
	                    if($is_collage_product && $group_buy_type == 2){
                            if($shopcode_onoff==1 && ($shopcode_limit==3 || ($shopcode_limit==1 && $group_id<0)|| ($shopcode_limit==2 && $group_id>0))){
                                echo "style='display:block;'";
                            }else{
                                echo "style='display:none;'";
                            }                           
                            
                        }
	                }else{//抱抱团
	                    if($group_id>0){//参团不能用购物币
	                        echo "style='display:none;'";
	                    }else{//开团才能用购物币
	                        if($join_bbt_times>0){//已经开过团，非首次开团可以用
	                            echo "style='display:block;'";
	                        }else{//首次开团
	                            if($if_bbt_curr_use==0){//用户不是团长，或，用户是团长但后台设置不可使用购物币
	                                echo "style='display:none;'";
	                            }else{//团长开团，并且后台开启了可使用购物币
	                                echo "style='display:block;'";
	                            }
	                        }
	                    }
	                }
	            }
            ?>
            >

            <?php if($if_bbt==0){//普通拼团
                        if($is_collage_product && $group_buy_type == 2){
                            if($shopcode_onoff==1 && ($shopcode_limit==3 || ($shopcode_limit==1 && $group_id<0)|| ($shopcode_limit==2 && $group_id>0))){
                                // $curr_arr[$supply_id_arr] = floor($curr_arr[$supply_id_arr]*$shopcode_precent*0.01*100)/100;
                                $collage_currency = floor($sum_price*$shopcode_precent*0.01*100)/100;

                                // if($curr_arr[$supply_id_arr] > $collage_currency){
                                	$curr_arr[$supply_id_arr] = $collage_currency;
                                // }
                            }                         
                        }
                    }
            ?>

              <div class="top">
                <span>共<?php echo $user_currency;?><?php echo $custom;?>(可抵扣<a id="deductible_curr_<?php echo $supply_id_arr;?>"><?php echo $curr_arr[$supply_id_arr];?></a>)</span>
                <input type="checkbox" id="checkbox_c1" class="chk_3" >
                <label for="checkbox_c1" open_val="0" supply_id="<?php echo $supply_id_arr;?>" class="open_curr" id="open_curr_<?php echo $supply_id_arr;?>">
                      <div class="slide_body"></div>
                      <div class="slide_block"></div>
                </label>
              </div>
              <div class="currency_<?php echo $supply_id_arr;?>" style="display:none">
                  <div class="line"></div>
                  <div class="bottom">

                    <input onkeyup="clearNoNum(this);" max_currr="<?php echo $user_currency;?>" class="user_currency" supply_id="<?php echo $supply_id_arr;?>" id="user_currency_<?php echo $supply_id_arr;?>"  placeholder="请输入抵用<?php echo $custom;?>数量" value="">
                  </div>

              </div>
            </div>
            <!--购物币-->



            <?php

            }
            ?>

				<?php if($sum_is_invoice >0){?>

				<!--发票抬头-->
				<div class="list-one">
					<div class="left-title">
					   <span>发票抬头:</span>
					</div>
					<div class="center-content1 text-hidden">

					   <input type="text"  placeholder="请输入发票抬头，否则为个人发票" class="in-text invoice">
					</div>
				</div>
				<div class="line"></div>
				<!--发票抬头-->
				<?php } ?>


				<?php if( 1 == $is_identity && $sum_p_is_identity > 0 ){?>

				<!--身份证-->
				<div class="list-one">
					<div class="left-title">
					   <span>身份证:</span>
				    </div>
				    <div class="center-content1 text-hidden">

					   <input type="text" placeholder="" class="in-text indentity" value="<?php echo $identity;?>" ii=<?php echo $ii ;?> style="width:80%;" readonly >
					   <span style="margin-left:10px;font-size:13px;" onclick="javascript:window.location.href='edit_identity.php?customer_id=<?php echo $customer_id_en;?>&aid=<?php echo $add_keyid;?>'">编辑</span>
				    </div>
				</div>
				<div class="line"></div>
				<!--身份证-->
				<?php } ?>

				<?php if($sum_is_Pinformation>0 && $total_is_Pinformation == 1 ){?>

				<!--必填信息-->
				<div class="list-one info" supply_id="<?php echo $supply_id_arr;?>"  pid="<?php echo substr($PID_str,0,-1);?>" pros="<?php echo substr($PID_pros,0,-3);?>" ii=<?php echo $ii ;?>>
					<div class="left-title">
					   <span>必填信息:</span>
				    </div>
				    <div class="right-action">
					   <img src="./images/vic/right_arrow.png" width="10" height="20">
				    </div>
				</div>
				<div class="line"></div>
				<!--必填信息-->
				<?php } ?>
				
				<div class="list-one">
					<div class="left-title">
					   <span style="color: #fff !important;background-color:#FF0001;padding: 0 10px;">姓名:</span>
				    </div>
				    <div class="center-content1 text-hidden">
					<!--By Code048 20181126 -->

						<input type="text" value="<?php echo $zusername;?>" id="username" class="in-text">

				    </div>
				</div>
				<div class="line"></div>

				<!--买家留言-->
				<div class="list-one">
					<div class="left-title">
					   <span style="color: #fff !important;background-color:#FF0001;padding: 0 10px;">手机号:</span>
				    </div>
				    <div class="center-content1 text-hidden">
					<!--By Code048 20180722 -->
						<?php if(empty($user_info)) {?>
								<input type="text" placeholder="请输入您的手机号" id="remark" class="in-text remark" ii=<?php echo $ii ;?>>
						<?php } else {?>
								<input type="text" value="<?php echo $user_info?>" id="remark" class="in-text remark" ii=<?php echo $ii ;?>>
						<?php }?>
				    </div>
				</div>
				<div class="line"></div>
				<!--买家留言-->
				<!--收货信息（门牌）-->
				<div class="list-one">
					<div class="left-title">
					   <span style="color: #fff !important;background-color:#FF0001;padding: 0 10px;">收货地址:</span>
				    </div>
				    <div class="center-content1 text-hidden">
						<?php if(empty($door_num)){?>
							<input type="text" placeholder="" id="door_num" class="in-text door_num" ii=<?php echo $ii ;?>>
						<?php } else {?>
							<input type="text" value="<?php echo $door_num?>" id="door_num" class="in-text door_num" ii=<?php echo $ii ;?>>
						<?php }?>	
				    </div>
				</div>
				<!--收货信息（门牌）-->	
				<div class="line"></div>
				<!--收货时间	
				<div class="list-one">
					<div class="left-title">
					   <span style="color: #fff !important;background-color:#FF0001;padding: 0 10px;">收货时间:</span>
				    </div>
				    <div class="center-content1 text-hidden">
						<?php if(empty($cargo_time)){?>
							<input type="text" placeholder="" id="cargo_time" class="in-text cargo_time" ii=<?php echo $ii ;?>>
						<?php } else {?>	
							<input type="text" value="<?php echo $cargo_time?>" id="cargo_time" class="in-text cargo_time" ii=<?php echo $ii ;?>>
						<?php }?>	
				    </div>
				</div>
				<div class="line"></div>
				收货时间-->								
				<div class="list-one-right">
					<span>共<?php echo $sum_rcount;?>件</span>
					<span class="margin-left-span">合计:</span>
					<span class="span3">
						<span <?php if($using_exchange_type == 1 || $sum_need_integral == 0)
						echo "style='display:none;'";?>  class="choose_shop_integral">
							<?php echo $sum_need_integral.'('.$shop_int_name.') +';?></span>
						<span <?php if($using_exchange_type == 0 || $sum_need_store_integral == 0)
						echo "style='display:none;'";?>  class="choose_store_integral">
							<?php echo $sum_need_store_integral.'('.$store_int_name.') +';?></span>
						<span class="express_span">
							<?php if(OOF_P != 2) echo OOF_S ?>
							<?php echo number_format($price_express,2);?>
							<?php if(OOF_P == 2) echo OOF_S ?>
						</span>
					</span>
				</div>
				<input type="hidden" class="is_theirself"  value='0'/>
				<input type="hidden" class="sum_express_supply"  value='<?php echo $sum_express?>'/>
				<input type="hidden" class="sum_price_supply" id="sum_price_supply_<?php echo $supply_id_arr;?>"  value='<?php echo $sum_price?>'/>
			</div>
		</li>

	<?php
		$all_rcount += $sum_rcount;		//产品总的数量
		$all_price += $sum_price;		//产品总的金额
		$all_express += $sum_express;	//产品总的快递费用
		$all_pro_weight += $sum_pro_weight;	//产品总的重量
		$all_tax_total += $tax_money; 		//产品总的税收
		$sum_all_money  += $price_express ;	//产品总的金额 + 产品总的快递运费
		$ii ++;



	}

	?>
	</ul>

	</div>
	<!--产品信息-->

	<?php

	//if($isOpenCurrency == 1 ){
	?>
	<!--购物币-->
	<!--li class="itembutton">
      <div class="top">
        <span>使用<?php echo $custom;?>(可用<?php echo $custom.':'.$user_currency;?>)</span>
        <input type="checkbox" id="checkbox_c1" class="chk_3" >
        <label for="checkbox_c1" open_val="0" class="open_curr">
              <div class="slide_body"></div>
              <div class="slide_block"></div>
        </label>
	  </div>
	  <div class="currency" style="display:none">
		  <div class="line"></div>
		  <div class="bottom">

			<input onkeyup="clearNoNum(this);" max_currr="<?php echo $user_currency;?>" class="user_currency"  placeholder="请输入抵用<?php echo $custom;?>数量" value="">
		  </div>
	  </div>
    </li-->
	<!--购物币-->
	<?php

	//}
	?>

	<!--优惠券-->
	<?php

	//查询用户可用的优惠券

		// $coupon_count = 0;
		// $query = "SELECT count(1) as coupon_count FROM weixin_commonshop_couponusers WHERE user_id=".$user_id." AND customer_id=".$customer_id." AND isvalid=true AND type=1 AND is_used=0 AND deadline >='".date("Y")."-".date("m")."-".date("d")." ".date("H").":".date("i").":".date("s")."' ";
		// $result=_mysql_query($query)or die('Query failed'.mysql_error());
		// while($row=mysql_fetch_object($result)){
			// $coupon_count = $row->coupon_count;
		// }
	?>

	<!-- <li class="itembutton">

      <div class="top select_coupon button buttonclick" onclick="go_select_coupon();" open_val="0" >
			<span>优惠券</span>


		<?php //if($select_coupon_id>0){	//选择后的优惠券详情?>

			<!-- <span class="select_coupon_span_r">
			<?php echo '（满'.$rtn_coupon_array[0].'<?php echo OOF_T ?>优惠'.$rtn_coupon_array[1].'<?php echo OOF_T ?>）' ;?>
			</span>  -->

        <?php //}else{					//默认?>


				<!--<span class="select_coupon_span_r">您有<?php echo $coupon_count?>张可用的优惠券</span>

		<?php //}?>


		  <div class="right-jiantou" >
			 <img src="./images/vic/right_arrow.png" width="10" height="20">
		  </div>

	 </div>


    </li>-->

	<!--优惠券-->

	<!--会员卡折扣-->
	<?php  /*			//暂时不用选择会员卡折扣
	$card_count = 0;
	$query_card = "SELECT count(1) as card_count from weixin_card_members as wcm inner join weixin_cards as wc on wcm.card_id=wc.id and wc.customer_id=".$customer_id." and wcm.isvalid=true and wc.isvalid=true and  wcm.user_id=".$user_id." ";
	//echo $query_card;
	$result=_mysql_query($query_card)or die('Query failed'.mysql_error());
	while($row=mysql_fetch_object($result)){
		$card_count = $row->card_count;
	}
	if($card_count>0){ 		//当用户拥有会员卡，才显示

	?>

	<li class="itembutton">
      <div class="top select_card" id="card" onclick="location.href='select_cards.php?customer_id=<?php echo $customer_id_en?>;'">

        <?php if($select_card_id>0){	//选择后的会员卡详情?>

			<span>
			<?php //echo $rtn_card_array[3].'：'.'余额：'.$rtn_card_array[0].',积分：'.$rtn_card_array[1].'，折扣：'.$rtn_card_array[2].'%' ;?>
			<?php echo $rtn_card_array[3].'：折扣：'.$rtn_card_array[2].'%' ;?>
			</span>

        <?php }else{					//默认?>

			<span>请选择会员卡折扣</span>

		<?php }?>
		<!--  <span class="card_str">请选择会员卡折扣</span> -->
		  <div class="right-jiantou" >
			 <img src="./images/vic/right_arrow.png" width="10" height="20">
		  </div>
	  </div>



    </li>

	<?php } */?>
	<!--会员卡折扣-->

	<!--会员卡折扣-->
	<?php  //会员卡折扣用商城绑定的会员卡
	$card_member_id = -1;
	$level_id = -1;
        //+ 韦 14:41 2016/9/3 定义在这里
        $discount = 100;    //默认折扣100 不打折
	//查找用户是否有商城会员卡，查ID和等级
	$query = "select id,level_id from weixin_card_members where isvalid=true  and user_id=".$user_id." and card_id=".$shop_card_id."";
	//echo $query;
	$result=_mysql_query($query)or die('Query failed'.mysql_error());
	while($row=mysql_fetch_object($result)){
		$card_member_id = $row->id;
		$level_id = $row->level_id;

	}
	if($card_member_id>0){

					//-----会员卡卡名
					$cardname = '';
					$query2 = "select name from weixin_cards where isvalid=true and customer_id=".$customer_id." and id=".$shop_card_id."";
					$result2=_mysql_query($query2)or die('Query failed'.mysql_error());
					while($row2=mysql_fetch_object($result2)){
						$cardname = $row2->name;
						break;
					}
					//-----会员卡剩余金额
					$query2 = "SELECT id,remain_consume from weixin_card_member_consumes where isvalid=true and  card_member_id=".$card_member_id;

					$result2 = _mysql_query($query2) or die('w661 Query failed: ' . mysql_error());
					while ($row2 = mysql_fetch_object($result2)) {
						$card_remain = $row2->remain_consume;
						break;
					}
					$card_remain = round($card_remain, 2);
					//-----会员卡剩余金额

					//-----会员卡剩余积分
					$query2 = "SELECT id,remain_score from weixin_card_member_scores where isvalid=true and  card_member_id=".$card_member_id;
					$result2 = _mysql_query($query2) or die('w669 Query failed: ' . mysql_error());
					$remain_score=0;
					while ($row2 = mysql_fetch_object($result2)) {
						$remain_score = $row2->remain_score;	//会员卡剩余积分
						break;
					}
					$remain_score = round($remain_score, 2);
					//-----会员卡剩余积分

					//- 韦
					//$discount = 100;		//默认折扣100 不打折
					if($level_id >0){
						//----查找会员卡等级折扣
						$query2 = "SELECT discount,title from weixin_card_levels where isvalid=true and  id=".$level_id;

						$result2 = _mysql_query($query2) or die('w678 Query failed: ' . mysql_error());
						$level_name = "";
						$discount = 100;		//默认折扣100 不打折
						while ($row2 = mysql_fetch_object($result2)) {
							$discount = $row2->discount;		//会员卡折扣
							$level_name = $row2->title;			//会员卡等级名称
							break;
						}
					}
					if(!empty($level_name)){
					  $cardname = $cardname."(".$level_name.")";
					}
					//----查找会员卡等级折扣



				}
	if($card_member_id>0){ 		//当用户拥有会员卡，才显示

	?>

	<li class="itembutton" <?php if($is_collage_product && $group_buy_type == 2){echo "style='display:none;'";}?>>
      <div class="top">
        <span>使用会员卡折扣</span>
        <input type="checkbox" id="checkbox_c2" class="chk_3" >
        <label for="checkbox_c2" open_val="0" class="open_card">
              <div class="slide_body"></div>
              <div class="slide_block"></div>
        </label>
	  </div>
	  <div class="card" style="display:none">
		  <div class="line"></div>
		  <div class="bottom">
			<div class="card_info">

			<p><?php echo $cardname.'：' ?></p>
			<p><?php echo '余额：'.$card_remain.'，积分：'.$remain_score.'，折扣：'.$discount.'%' ;?></p>

			</div>
		  </div>
	  </div>
    </li>

	<?php } ?>
	<!--会员卡折扣-->

	<?php

	if($ispay_on == 1 && $delivery_on == 1 && $is_orderingretail != 1){ ?>
    <!--货到付款-->
    <div class="itembutton" style="margin-bottom:15px;">
      <div class="top">
        <span>货到付款</span>
        <input type="checkbox" id="checkbox_c3" class="chk_3" >
        <label for="checkbox_c3" open_val="0" supply_id="" class="payondelivery" >
              <div class="slide_body"></div>
              <div class="slide_block"></div>
        </label>
      </div>
    </div>
    <!--货到付款-->
    <?php } ?>

	<!--收货时间-->
	<?php
	$sendtime_Rcount = 0;
	$query_sendtime="select count(1) as sendtime_Rcount from weixin_sendtimes where isvalid=true and customer_id=".$customer_id;
	//echo $query_sendtime;
	$result=_mysql_query($query_sendtime)or die('Query failed'.mysql_error());
	while($row=mysql_fetch_object($result)){
		$sendtime_Rcount = $row->sendtime_Rcount;
	}
	if($sendtime_Rcount>0){ 		//当商家设置了时间则显示

	?>


	<li class="itembutton hide" <?php if($is_collage_product && $group_buy_type == 2){echo "style='display:none;'";}?>>      <div class="top select_sendtime" id="" onclick="location.href='select_sendtime.php?customer_id=<?php echo $customer_id_en?>;'">
      <div class="top select_sendtime button buttonclick" onclick="location.href='select_sendtime.php?customer_id=<?php echo $customer_id_en?>;'">

        <?php if($sendtime_id>0){	//选择后的收货时间详情?>

			<span>

			<?php echo '送货时间：'.$rtn_sendtime_array[1];?>
			</span>

        <?php }else{					//默认?>


			<span>请选择送货时间</span>

		<?php }?>
		<!--  <span class="sendtime_str">请选择收货时间</span> -->
		  <div class="right-jiantou" >
			 <img src="./images/vic/right_arrow.png" width="10" height="20">
		  </div>
	  </div>



    </li>
	<?php } ?>
	<?php if( $sum_all_supply_pros_need_score > 0 ){ ?>
    <li class="itembutton">
    	<div class="top">
    		<span>当前需要积分<span id="jifen"><?php echo $sum_all_supply_pros_need_score; ?></span></span>
    		<p class="keyong">可用积分<?php echo $remain_score; ?></p>
    	</div>
    </li>
	<?php } ?>

	<!--积分类型-->
	<?php if($sum_need_integral >0 || $sum_need_store_integral >0){?>
	<li class="itembutton">

		<div class="white-list">
			<div class="list-one express-type button buttonclick choose_integral_type"  style="padding: 15px 1.4% 15px 1%;">
			   <div class="left-title">
				   <span>积分类型</span>
			   </div>
			   <div class="center-content" style="width: 58%">
					<span <?php if($using_exchange_type == 1) echo "style='display:none'"?>
						class="choose_shop_integral">
						<span><?php echo $shop_int_name;?></span>
					</span>
					<span <?php if($using_exchange_type == 0) echo "style='display:none'"?>
						class="choose_store_integral">
						<span><?php echo $store_int_name;?></span>
					</span>
			   </div>
				    <div class="right-action">
				   <img src="./images/vic/right_arrow.png" width="10" height="20">
			    </div>
			</div>
		</div>

	</li>
	<? }?>
 	<!--积分类型-->
	<?php
		if ( $is_diy_area && $default_diy_area_id_f > 0){
	?>
<!--	
	Code048 20181126 配送位置注释
	<li class="itembutton">
      <div class="top diy_team button buttonclick">

        <?php if($diy_area_id>0){	//选择后的收货时间详情?>

			<span><?php $diy_check = 1;
					echo '已匹配配送位置：'.$rtn_diy_area_array[1];
				?>
			</span>

        <?php }else{					//默认?>

			<span>
			<?php
			if($diy_area_id!=-2){
				if( !empty( $default_diy_areaname ) ){
					$diy_check = 1;
					echo '已匹配配送位置：'.$default_diy_areaname;
				}else{
					echo "请选择配送位置";
				}
			}else{
					$diy_check = 1;
					echo '没有我的配送位置';
			}
			?>
			</span>

		<?php }?>
		  <span class="sendtime_str">请选择收货时间</span> 
		  <div class="right-jiantou" >
			 <img src="./images/vic/right_arrow.png" width="10" height="20">
		  </div>
	  </div>



    </li>
	-->
		<?php }?>
	<!--收货时间-->

	<!--产品金额总明细-->
	<li class="foote">

		<div class="top choose_shop_integral"
			<?php if($sum_need_integral == 0 || $using_exchange_type==1) echo "style='display:none'"; ?>>
			<div class="left">需付<?php echo $shop_int_name;?></div>
			<div class="right" id="sum_need_integral"
			sum_need_integral="<?php echo $sum_need_integral;?>">
			<?php echo $sum_need_integral;?>
			</div>
		</div>

		<div class="top choose_store_integral"
			<?php if($sum_need_store_integral == 0 || $using_exchange_type==0) echo "style='display:none'"; ?>>
			<div class="left">需付<?php echo $store_int_name;?></div>
			<div class="right" id="sum_need_store_integral"
			sum_need_store_integral="<?php echo $sum_need_store_integral;?>">
			<?php echo $sum_need_store_integral;?>
			</div>
		</div>

        <div class="top">
          <div class="left">商品金额</div>
          <div class="right" id="sum_price" sum_price="<?php echo $all_price;?>">
		  <?php if(OOF_P != 2) echo OOF_S ?>
		  <?php echo number_format($all_price,2);?>
		  <?php if(OOF_P == 2) echo OOF_S ?>
		  </div>
        </div>
		<?php if($all_tax_total > 0){?>
        <div class="top">
          <div class="left">税收</div>
          <div class="right" id="sum_tax" sum_tax="<?php echo $all_tax_total;?>">+
		  <?php if(OOF_P != 2) echo OOF_S ?>
		  <?php echo $all_tax_total;?>
		  <?php if(OOF_P == 2) echo OOF_S ?>

		  </div>
        </div>
		<?php }?>
        <div class="top">
          <div class="left">优惠</div>
          <div class="right" id="save_money" save_money='0'></div>
        </div>
		 <?php if($is_extension_deductible == 1 && $issell_model == 2){?>
        <div class="top">
          <div class="left">复购推广优惠</div>
          <div class="right" id="extension_deductible" >-<?php if(OOF_P != 2) echo OOF_S ?><?php echo $sum_self_reward;  ?><?php if(OOF_P == 2) echo OOF_S ?></div>
        </div>
		<?php }?>
		 <?php if($is_shop_deductible == 1 && $issell_model == 2){?>
        <div class="top">
          <div class="left">复购店铺优惠</div>
          <div class="right" id="shop_deductible" >-<?php if(OOF_P != 2) echo OOF_S ?><?php echo $sum_shop_reward;  ?><?php if(OOF_P == 2) echo OOF_S ?></div>
        </div>
		<?php }?>
        <?php if($isOpenCurrency == 1){?>
        <div class="top">
          <div class="left"><?php echo $custom;?>抵扣</div>
          <div class="right" id="curr_money" curr_money="0"></div>
        </div>
		<?php }?>
        <div class="top">
          <div class="left">运费</div>
          <div class="right" id="sum_express" sum_express="<?php echo $all_express;?>">+
		  <?php if(OOF_P != 2) echo OOF_S ?>
		  <?php echo $all_express;?>
		  <?php if(OOF_P == 2) echo OOF_S ?>
		  </div>
        </div>

    </li>
    <div class="kong"></div>
	<!--产品金额总明细-->
	<!--代付信息-->
	<div class="pay_desc" style="display:none;">
		<span style="font-size:16px;display:block;margin-top:10px;">对你的好友说：</span>
		<textarea class="payother_desc" rows="6" cols="32" placeholder="蛋蛋的忧伤，钱不够了，你能不能帮我先垫付下" style="width:90%;margin:auto;"></textarea>
		<div class="pay_desc_btn">确定</div>
	</div>
	<div class="shadow" style="display:none;"></div>
	<!--代付信息-->

	<!-- <div class=" popup-memu" id = "new_zhifuPannel"></div> -->

	<div class=" popup-memu" id = "zhifuPannel">
		<div class="list-one popup-menu-title">
            <span class="sub">选择支付方式</span>
        </div>

	<!--微信支付区域 -->

	<?php  if($from_type == 1){			//目前支持微信端的微信支付，app微信支付暂不支持?>

		<?php if( $is_weipay ) {?>
			<div class="line"></div>
			<div class = "popup-menu-row" data-value="微信支付">
				<img src="images/np-1.png">
				<span class="font">微信支付</span>
			</div>
		<?php }?>

		<?php if( $is_payother ) {?>
		<div class="line"></div>
		<div class = "popup-menu-row" data-value="找人代付">
             <img src="images/np-6.png">
        	<span class="font">找人代付</span>
        </div>

		<?php }?>

	<?php  }else{						//网页端、app?>
	<!--非微信支付区域 -->

		<?php if( $is_alipay) {?>
		<div class="line"></div>
		<div class = "popup-menu-row" data-value="支付宝支付">
             <img src="images/np-4.png">
        	<span class="font">支付宝支付</span>
        </div>

		<?php };?>

	<?php  } ?>

	<!--公共支付区域-->

	<?php if( $iscard && $card_member_id>0 ) {?>
		<div class="line"></div>
        <div class = "popup-menu-row" data-value="会员卡余额支付">
             <img src="images/np-2.png">
        	<span class="font">会员卡余额支付</span>
        </div>
	<?php }?>


	<?php if($is_payChange){ ?>
	<div class="line"></div>
    <div class = "popup-menu-row" data-value="零钱支付">
             <img src="images/np-3.png">

        	<span class="font">钱包零钱支付</span>
    </div>
	<?php } ?>

	<?php if($is_yeepay){ ?>
	<div class="line"></div>

    <div class = "popup-menu-row" data-value="易宝支付">
             <img src="images/np-9.png">
        	<span class="font">易宝支付</span>
    </div>
	<?php } ?>

	<!--        京东支付暂时屏蔽         -->
<!-- 	<?php if(1){ ?>
	<div class="line"></div>
    <div class = "popup-menu-row" data-value="京东支付">
             <img src="images/np-10.png">
        	<span class="font">京东支付</span>
    </div>
	<?php } ?> -->
	<!--        京东支付暂时屏蔽         -->

	<?php if($is_pay){ ?>
	<div class="line"></div>
	<div class = "popup-menu-row" data-value="暂不支付">
		 <img src="images/pay_no.png">
		<span class="font">暂不支付</span>
	</div>
	<?php } ?>
        <div class="line"></div>
		 <div class = "popup-menu-row" data-value="PayPal支付">

             <img src="images/np_7.png">
        	<span class="font">PayPal</span>
        </div>

	<!-- <?php if( $is_allinpay ) {?>
		 <div class="line"></div>
         <div class = "popup-menu-row" data-value="通联支付">

            <img src="images/np_8.png">
        	<span class="font">通联支付</span>
        </div>
	<?php };?>
	<?php if( $isshop ) {?>
		<div class="line"></div>
		<div class = "popup-menu-row" data-value="货到付款">

             <img src="images/np_5.png">
        	<span class="font">货到付款</span>
        </div>

	<?php };?>
	<?php if( $is_paypal ) {?>
        <div class="line"></div>
		 <div class = "popup-menu-row" data-value="PayPal支付">

             <img src="images/np_7.png">
        	<span class="font">PayPal</span>
        </div>
    <?php };?>


     -->

    <!--公共支付区域-->
	</div>
	<div data-am-widget="navbar" class="am-navbar am-cf am-navbar-default  am-no-layout bottomButton">
		<div class = "bottomButton-left">

			<span>共<?php echo $all_rcount;?>件</span>
			<span>合计:</span>

			<span class = "bottomButton-left-right-span" id="sum_all_money"  sum_all_money="" temp_sum_all_money="" ></span>
		</div>
        <?php if($product_isnone==0){?>
		<div class="bottomButton-rightWrapper new_pay" id="" style="margin-top:7px">
			<span class="">立即支付</span>
		</div>
        <?php }else{ ?>
            <div class="bottomButton-rightWrapper " id="" style="margin-top:7px">
			<span onclick="return alert('存在已下架商品，请重新挑选！');">立即支付</span>
		</div>
        <?php }?>

	</div>
	 <div class="am-dimmer am-active" data-am-dimmer="" style="display: none;"></div>

	 <input type="hidden" class="sum_all_money"  value="<?php  echo $sum_all_money;?>">
	 <input type="hidden" class="all_pro_weight" value="<?php  echo $all_pro_weight;?>">

	 <input type="hidden" class="diy_area_id" value="
	 <?php if($diy_area_id>0)
		{echo passport_encrypt((string)$diy_area_id);
			} else{
				if($diy_area_id==-2){
					echo -1;
				}else{
					if( empty($default_diy_areaname) ){
						echo passport_encrypt((string)$default_diy_area_id_f);
					} else{
					echo passport_encrypt((string)$default_diy_area_id);
					}
				}
			} ?>">
	 <input type="hidden" class="aid" value="<?php echo passport_encrypt((string)$add_keyid) ;?>">
	 <input type="hidden" class="add_keyid" value="<?php echo $add_keyid ;?>">
	 <input type="hidden" class="select_card_id" value="<?php echo passport_encrypt((string)$card_member_id) ;?>">
	 <input type="hidden" class="select_coupon_id" value="">
	 <!-- <input type="hidden" class="sendtime_id" value="<?php echo $sendtime_id ;?>">	 -->

         <?php
         $rtn_sendtime_str = '';
         if(!empty($rtn_sendtime_array[1])){
             $rtn_sendtime_str = $rtn_sendtime_array[1];
         }
         ?>
	 <input type="hidden" class="sendtime" value="<?php echo $rtn_sendtime_str ;?>">
	 <input type="hidden" class="is_payother" value="0">
	 <input type="hidden" class="sendstyle_express" value="<?php echo $sendstyle_express ;?>">
	 <input type="hidden" class="sendstyle_pickup" value="<?php echo $sendstyle_pickup ;?>">
	 <input type="hidden" class="sum_all_supply_pros_need_score" value="<?php echo $sum_all_supply_pros_need_score ;?>">
	 <input type="hidden" class="sum_need_integral" value="<?php echo $sum_need_integral ;?>">
	 <input type="hidden" class="identity_str" value="<?php echo $is_identity.'_'.$is_uploadidentity.'_'.$sum_p_is_identity.'_'.$sum_ID_tf ;?>">
	 <input type="hidden" class="close_sid" value="-1">
	 <input type="hidden" class="sum_self_reward" val="<?php echo ($sum_self_reward);?>"  value="<?php echo MD5($sum_self_reward);?>">
	 <input type="hidden" class="sum_shop_reward" val="<?php echo ($sum_shop_reward);?>" value="<?php echo MD5($sum_shop_reward);?>" >
	<!--测试-->
	<div id="loading" style="display:none">
	<div style="display:block" id="q_Msgbox" class="zeng_msgbox_layer_wrap"><span id="mode_tips_v2" style="z-index:10000" class="zeng_msgbox_layer"><span class="gtl_ico_clear"></span><img alt="" src="images/loading.gif">正在加载中，请稍后...<span class="gtl_end"></span></span></div>
	<div class="zeng_msgbox_layer_wrap" id="q_Msgbox" style=" display:block"></div>
	</div>
	<!-- 选择积分类型 -->
<div id="gyuji" style="position:fixed;top:0;z-index:2900;left:0;background:#000000;opacity:0.5;width:100%;height:100%;display:none;">
</div>
<div class="jifen-type-alert">
	<p class="jifen-title">选择积分类型</p>
	<?php if($sum_need_integral > 0 && $shop_integral_onoff == 1){?>
	<div class="jifen-content">
		<div class="left-text"><?php echo $shop_int_name;?></div>
		<div class="select-box <?php if($using_exchange_type == 0) echo 'add-gou'?>" val="shop" ind="0"></div>
	</div>
	<?php }?>
	<?php if($sum_need_store_integral > 0 && $store_integral_onoff == 1){?>
	<div class="jifen-content">
		<div class="left-text"><?php echo $store_int_name;?></div>
		<div class="select-box <?php if($using_exchange_type == 1) echo 'add-gou'?>" val="store" ind="1"></div>
	</div>
	<?php }?>
	<div class="jifen-btn-box">
		<div id="jifen-cancle-btn" class="cancle-btn skin-color">取消</div>
		<div id="jifen-sure-btn" class="sure-btn skin-color">确定</div>
	</div>
</div>

<!-- <div id="gyuji" style="position:fixed;top:0;z-index:2900;left:0;background:#000000;opacity:0.5;width:100%;height:100%;display:none;">

</div> -->
<!-- <div class="am-share" id="pass_w" style="width:100%;position: fixed;top:150px;z-index: 3000;display:none;height:201px">
    <div class="box">
        <span class="guanbicha">X</span>
        <h1>输入支付密码</h1>
        <label for="ipt">
            <ul id="p_pwd" pay_type="card">
                <li></li>
                <li></li>
                <li></li>
                <li></li>
                <li></li>
                <li></li>
            </ul>
        </label>
        <input type="text" id="ipt" maxlength="6"> -->
        <!--     <div style="width:100%;text-align: right;padding:10px;"> <a onclick='xiugai_pass();'>密码管理</a></div>
            <a class="commtBtn" onclick="commitBtn();" style="display:none;">确认</a> -->
    <!-- </div>
</div>
<div class="am-dimmer-new am-active" data-am-dimmer="" style="display: none;"></div> -->

<!--代付信息-->
<!-- <div class="pay_desc" style="display:none;">
    <span style="font-size:16px;display:block;margin-top:10px;">对你的好友说：</span>
    <textarea class="payother_desc" rows="6" cols="32" placeholder="蛋蛋的忧伤，钱不够了，你能不能帮我先垫付下" style="width:90%;margin:auto;"></textarea>
    <div class="pay_desc_btn">确定</div>
</div>
<div class="shadow" style="display:none;"></div> -->
<!--代付信息-->
<!-- <div class="zhifuthree">
<div class="list-one popup-menu-title">
	<img class="zhifuthimg" src="images/ico_zuo.png">
    <span class="sub">选择支付方式</span>
</div>
 <div id="new_zhifuPannel" style="display: block;">
   <div class="new_popup-menu-row" data-value="yeepay" onclick="new_popup(this);">
    <img src="//admin.weisanyun.cn/weixinpl/up/1/3243/yeepay/j.jpg" />
    <div class="newdiv">
     <p class="newfont">易宝支付</p>
     <p class="newzhifup">hahah </p>
    </div>
   </div>
   <div class="line"></div>
   <div class="new_popup-menu-row" data-value="yeepay" onclick="new_popup(this);">
    <img src="//admin.weisanyun.cn/weixinpl/up/1/3243/yeepay/j.jpg" />
    <div class="newdiv">
     <p class="newfont">易宝支付</p>
     <p class="newzhifup">hahah </p>
    </div>
   </div>
   <div class="line"></div>
   <div class="new_popup-menu-row" data-value="yeepay" onclick="new_popup(this);">
    <img src="//admin.weisanyun.cn/weixinpl/up/1/3243/yeepay/j.jpg" />
    <div class="newdiv">
     <p class="newfont">易宝支付</p>
     <p class="newzhifup">hahah </p>
    </div>
   </div>
   <div class="line"></div>
   <div class="new_popup-menu-row" data-value="jdpay" onclick="new_popup(this);">
    <img src="//admin.weisanyun.cn/weixinpl/up/1/3243/jdpay/pay_ok.png" />
    <div class="newdiv">
     <p class="newfont">京东支付</p>
     <p class="newzhifup">京东ong</p>
    </div>
   </div>
   <div class="line"></div>
   <div class="new_popup-menu-row" data-value="alipay" onclick="new_popup(this);">
    <img src="//admin.weisanyun.cn/weixinpl/up/1/3243/alipay/QQ图片20161230162835.png" />
    <div class="newdiv">
     <p class="newfont">支付宝支付宝</p>
     <p class="newzhifup">12345677</p>
    </div>
   </div>
   <div class="line"></div>
   <div class="new_popup-menu-row" data-value="moneybag" onclick="new_popup(this);">
    <img src="//admin.weisanyun.cn/weixinpl/up/1/3243/moneybag/b.jpg" />
    <div class="newdiv">
     <p class="newfont">零钱支付</p>
     <p class="newzhifup">描述</p>
    </div>
   </div>
   <div class="line"></div>
   <div class="new_popup-menu-row" data-value="nopay" onclick="new_popup(this);">
    <img src="//admin.weisanyun.cn/weixinpl/up/1/3243/nopay/k.jpg" />
    <div class="newdiv">
     <p class="newfont">提单不支付</p>
     <p class="newzhifup">123123</p>
    </div>
   </div>
   <div class="line"></div>
   <div class="new_popup-menu-row" data-value="anotherpay" onclick="new_popup(this);">
    <img src="//admin.weisanyun.cn/weixinpl/up/1/3243/anotherpay/5050.jpg" />
    <div class="newdiv">
     <p class="newfont">找人代付</p>
     <p class="newzhifup">描述</p>
    </div>
   </div>
   <div class="line"></div>
   <div class="new_popup-menu-row" data-value="card" onclick="new_popup(this);">
    <img src="//admin.weisanyun.cn/weixinpl/up/1/3243/card/e.jpg" />
    <div class="newdiv">
     <p class="newfont">会员卡余额支付</p>
     <p class="newzhifup">描述</p>
    </div>
   </div>
   <div class="line"></div>
   <div class="new_popup-menu-row" data-value="paypal" onclick="new_popup(this);">
    <img src="//admin.weisanyun.cn/weixinpl/up/1/3243/paypal/g.jpg" />
    <div class="newdiv">
     <p class="newfont">paypal支付</p>
     <p class="newzhifup">description</p>
    </div>
   </div>
  </div>
  <div class="chakanmoveth">
  	<p class="pmoth">查看更多支付方式</p>
  	<img class="imgnoth" src="images/gengduoth.png">
  </div>
</div> -->
</body>

<script type="text/javascript">
	//货到付款
	// $(".payondelivery").click(function(){
	// 	var delivery = $(this).attr("open_val");
	// 	var de_pids  = new Array();
	// 	$(".product").each(function(i,o){
	// 		de_pids[i] = $(this).attr('pid');
	// 	});

	// 	if(delivery == 1)
	// 	{
	// 		btn_off($(this));
	// 		$(".new_pay span").html("立即支付");
	// 	}
	// 	else
	// 	{
	// 		btn_on($(this));
	// 		var obj = $(this);
	// 		$(".new_pay span").html("立即下单");
	// 		// $.post("order_form.php",{"op":"","pid":de_pids},function(res){
	// 		// 	if(res.status != "ok")
	// 		// 	{
	// 		// 		alert('该产品不支持货到付款');
	// 		// 		btn_off(obj);
	// 		// 		$(".new_pay span").html("立即支付");
	// 		// 	}
	// 		// },'json')
	// 		//check_delivery1

	// 	}

	// });
</script>

<script type="text/javascript">

  //判断从哪个端口进入
    <?php
    $page_port="";
	switch ($from_type)
	{
	case 1:
	  $page_port='wx';//微信端
	  break;
	case 2:
	  $page_port='app';
	  break;
	case 0:
	  $page_port='h5';
		break;
	}
    ?>

    var money_ex_express = 0; //最后付款金额减去快递费

	/*sz郑培强添加用于砍价活动--start*/
	var form_bargain_sz     = '<?php echo $form_bargain_sz;?>';
	var form_bargain_sz_data     = '<?php echo $form_bargain_sz_data;?>';
	/*sz郑培强添加用于砍价活动--end*/
	/*sz郑培强添加用于众筹活动--start*/
	var form_crowdfund_sz     = '<?php echo $form_crowdfund_sz;?>';
	var form_crowdfund_sz_data     = '<?php echo $form_crowdfund_sz_data;?>';
	/*sz郑培强添加用于众筹活动--end*/
	var page_port           = '<?php echo $page_port;?>';//从什么端口进入
	var customer_id      	= '<?php echo $customer_id ?>';
	var customer_id_en      = '<?php echo $customer_id_en ?>';
	var is_diy_area    		= '<?php echo $is_diy_area; ?>';	//自定义区域
	var default_diy_area_id_f = '<?php echo $default_diy_area_id_f; ?>';	//自定义区域
	var fromtype 			= '<?php echo $fromtype; ?>';
	var from_type 			= '<?php echo $from_type; ?>';
	var user_id 			= '<?php echo $user_id; ?>';
	var pid 				= '<?php echo $pid; ?>';
	var shop_card_id 		= '<?php echo $shop_card_id; ?>';
	var clean_cart  		= '<?php echo $clean_cart ; ?>';	//购物车数据
	console.log(clean_cart);
	var edit_type  			= 1;								//便于监听修改购物币使用
	var allpid_str			= '<?php echo $allpid_str;?>';	//所有pid
	var pidcount_str		= '<?php echo $pidcount_str;?>';	//所有产品数量
	var check_first_extend	= '<?php echo $check_first_extend;?>';	//是否符合首次推广奖励
	var sum_all_supply_pros_need_score = "<?php echo $sum_all_supply_pros_need_score; ?>";//产品所需积分
	var extend_money		= '<?php echo $extend_money;?>';	//首次推广奖励金额
	var IS_REDIS			= '<?php echo IS_REDIS;?>';		//是否开启IS_REDIS
	var diy_check			= '<?php echo $diy_check;?>';		//是否开启IS_REDIS
	var check_pay_password  = '<?php echo $check_pay_password;?>';//是否有设置支付密码（1:有;-1:没有）
	var is_collage_product_info  = '<?php echo $is_collage_product_info;?>';//是否走拼团路线，拼团标识_单独购买或团购_单独购买价格_团购价_活动id_团id
	var is_collage_product	= '<?php echo $is_collage_product;?>';		//是否拼团产品
	var group_buy_type	= '<?php echo $group_buy_type;?>';		//购买方式，1：单独购买，2团购
	var group_id	= '<?php echo $group_id;?>';		//团id
	var if_bbt      = '<?php echo $if_bbt;?>';          //是否抱抱团  0：否；1：是
    var sum_price   = '<?php echo $sum_price;?>';       //仅仅产品的总价，用于计算拼团购物币抵购
    var shopcode_onoff  = '<?php echo $shopcode_onoff;?>';
    var shopcode_limit  = '<?php echo $shopcode_limit;?>';
    var shopcode_precent = '<?php echo $shopcode_precent;?>';    //拼团购物币抵购比例

	var activitie_id	= '<?php echo $activitie_id;?>';		//活动id
	var rcount	= '<?php echo $rcount;?>';		//购买产品数量
	var is_use_free_coupon	= '<?php echo $is_use_free_coupon;?>';		//是否可以使用团长免单券，1是，0否
	var coupon_onoff	= '<?php echo $coupon_onoff;?>';		//拼团优惠券开关
	var allpid_str_len = allpid_str.length;
	allpid_str = allpid_str.substring(0,allpid_str_len-1);	//去最后一个逗号
	var delivery_time = "<?php echo $delivery_time;?>"; 	//预配送时间

    // 满赠活动(平台商品优惠价格)
    var platform_self_reward = '<?php echo $platform_self_reward ?>'
    var platform_shop_reward = '<?php echo $platform_shop_reward ?>'
    // 最高满赠价格
    var max_threshold = '<?php echo $max_threshold ?>'
    var platform_price_no_exchange = '<?php echo $platform_price - $total_exchange_price ?>';
    var local_id = customer_id+'_'+user_id+'_ex';
    var pro_arr = '<?php echo $exchange_list ?>'
    localStorage.setItem(local_id,pro_arr);
    var platform_exchange_envent_res1 = 0;
    var platform_exchange_envent_res3 = 0;
    var platform_exchange_user_curr_money = 0;
    var platform_exchange_deductible_money = 0;
    var platform_exchange = 0;
    var platform_exchange_coupon = 0;
    var platform_exchange_card = 0;
    var platform_price = '<?php echo $platform_price ?>'
    var platform_final_price = platform_price_no_exchange
    //满赠活动(平台商品优惠价格)

	var pidcount_str_len = pidcount_str.length;
	pidcount_str = pidcount_str.substring(0,pidcount_str_len-1);	//去最后一个逗号
	var is_check_password = "<?php echo $_SESSION['is_check_password_'.$user_id]; ?>"; //是否已经输入过支付密码
	var is_ban_use_coupon_currency = "<?php echo $is_ban_use_coupon_currency;?>";//是否禁止购物币和优惠券同时使用？0为不禁止 1为禁止
    var is_orderingretail_store = "<?php echo $is_orderingretail_store;?>"; //是否显示订货系统门店
    var is_extension_deductible = "<?php echo $is_extension_deductible;?>"; //是否使用推广奖励抵扣
    var is_shop_deductible = "<?php echo $is_shop_deductible;?>"; //是否使用店铺奖励抵扣
    var sum_shop_reward_en = ""; //是否使用店铺奖励抵扣
    var sum_self_reward_en = ""; //是否使用店铺奖励抵扣
    var using_exchange_type= "<?php echo $using_exchange_type?>";//积分兑换类型  0商城  1门店
    var is_int_exchange_order=0;	//是否是兑换活动积分，用于支付

	// console.log(allpid_str);
	// console.log(pidcount_str);
	/*********设置事件标识**********/
	var is_select_card 		= 0;		//是否使用会员卡

	var is_select_coupon 	= 0;		//是否使用优惠券
	var is_take_theirself 	= 0;		//是否使用自提
	var is_express 			= 1;		//是否使用快递  默认使用快递
	//var is_curr 			= 0;		//是否使用购物币
    var is_curr             = [];       //产品是否使用购物币数组
    var is_curr_count       = 0;       //开关计数器
    var is_ban_currency     = [];		//某商家是否禁用购物币数组

    var _Curr = get_curr_local();
    if(_Curr==''){
        var _Curr = new Array;
    }
    var close_sid = '-1';//关闭密码输入框用

    var ispay_on  = 0;  				//用户是否使用货到付款
	var is_plat_payondelivery = '<?php  echo $ispay_on;?>'; //平台是否支持


	/*********设置事件标识**********/
	var express_ondelivery = '<?php echo $is_express ?>';
	/*****缓冲变量*****/
	var card_discount 		= 0;		//会员卡折扣
	var card_discount_money = 0;		//会员卡折扣金额

	var coupon_money 		= 0;		//优惠券
	var user_curr_money 	= 0;			//购物币
	var user_shop_deductible 	= '<?php echo $sum_shop_reward; ?>';			//复购店铺优惠
	var user_extension_deductible 	= '<?php echo $sum_self_reward; ?>';		//复购推广优惠
	var is_express_arr = '<?php echo json_encode($is_express_arr) ?>';//订单是否有配送方式
	var buy_pid_arr    = '<?php echo json_encode($buy_pid_arr) ?>';//pid数组
		is_express_arr = JSON.parse(is_express_arr);
		buy_pid_arr    = JSON.parse(buy_pid_arr);

	var is_change_address = '<?php  echo $is_change_address;?>'; //是否修改了收货地址
	if( is_change_address == 1 ){
		localStorage.removeItem('orderingretail_store_<?php echo $user_id;?>');	//清空订货系统门店本地数据
		localStorage.removeItem('send_way_<?php echo $user_id;?>');	//清空配送方式本地数据
	}

	/*****缓冲变量*****/





	/***********设置事件本地存储***********/






	var envent_object = localStorage.getItem('envent_'+user_id); 	//读取localStorage的数据


	if(envent_object ==null || envent_object==''){

		var event_arr = {

			'event1':'',		//事件1
			'event2':'',		//事件2
			'event3':'',		//事件3
			'event4':'',		//事件4
			'event5':'',		//事件5
			'event6':'',		//事件6
			'event7':''			//事件7
		}

		var event_arr_json = JSON.stringify(event_arr);	//转JSON
		localStorage.setItem('envent_'+user_id,event_arr_json);			//初始化被动事件存入localStorage
		envent_object = localStorage.getItem('envent_'+user_id); 		//重新读取localStorage的数据
	}else{


	}
	var envent_object_arr = JSON.parse(envent_object);					//json转数组


	var industry_type = "shop";
	/************设置事件本地存储**********/
	/*新支付方式*/
	// function new_popup(obj){
	// 	// alert($(obj).data('value'));return;
	// 	new_togglePan_down();
	// 	thiss = $(obj);
	// 	new_check_limit(2,thiss);
	// 	// choose_pay_type(thiss);

	// }

	var area_str = '<?php echo $area_str?>';
	var o_shop_id = '<?php echo $o_shop_id; ?>'; //订货系统门店id
	// alert("o_shop_id: "+o_shop_id);

	$(function(){


		if(area_str!=''){
			showAlertMsgNoclose('提示','【'+area_str+'】收货地址中包含的此批行政区划名称有更新，请重新设置该地址再下单！','去设置',function(){
//				document.location = 'my_address.php?customer_id=<?php echo $customer_id_en?>&a_type=1';
			})
		}

		/********************事件开始*****************/
			envent_listen();
		/********************事件结束*****************/


		/********************跳转到必填信息*****************/
			$('.info').click(function(){
				thiss = $(this);
				go_to_info(thiss);
			});
		/********************跳转到必填信息*****************/

		/********************跳转到选择门店*****************/
			$('.store').click(function(){
				thiss = $(this);
				go_to_store(thiss);
			});
		/********************跳转到选择门店*****************/

		/********************跳转到选择优惠券*****************/
			$('.coupon').click(function(){
				this_supply_id=$(this).attr('supply_id');
				supply_is_curr=$("#open_curr_"+this_supply_id).attr('open_val');
				if(supply_is_curr == 1 && is_ban_use_coupon_currency == 1){
					alertAutoClose('购物币和优惠券不能同时使用',2000);

				}else{
					thiss = $(this);
					go_to_coupon(thiss);
				}

			});
		/********************跳转到选择优惠券*****************/

		/********************跳转到选择自定义区域*****************/
			$('.diy_team').click(function(){
				thiss = $(this);
				go_to_diy_area(thiss);
			});
		/********************跳转到选择自定义区域*****************/

		/********************选择支付方式*******************/
			$('.popup-menu-row').click(function(){
				togglePan_down();
				thiss = $(this);
				check_limit(2,thiss);
				// choose_pay_type(thiss);
			});

		/********************选择支付方式*******************/

	});


	/********************函数部分*********************/






	//用户触发事件
	var envent_listen = function(){

		//------事件监听 start

		//-----先加载完被动事件，在执行主动事件

		//被动
		_event_listen();				//被动事件监听
		//主动
		select_curr()					//选择购物币
		select_card();					//选择会员卡
		select_payondelivery();			//选择货到付款
		invoice_input_listen();			//填写发票
		remark_input_listen();			//填写备注



		//------事件监听 end

		sum_all_money();				//计算总金额

	}


	//根据保存到本地存储的最后触发的事件来计算价格
	function _event_listen(){

		var _object = localStorage.getItem('envent_'+user_id); 	//读取用户触发的事件localStorage的数据

		var _object_arr = JSON.parse(_object);							//json转数组

		if(_object_arr == null || _object_arr == ''){

		}else{		//根据不同的事件来调用方法

			if(_object_arr.event1 =='coupon'){


				select_coupon_listen();					//当事件1为优惠券，则使用优惠券方法

			}
			if(_object_arr.event1 =='card'){


				select_card_listen();						//当事件1为会员卡折扣，则使用会员卡折扣方法
			}


			if(_object_arr.event3 =='curr'){

				curr_listen();								//当事件3为购物币，则使用购物币方法

			}

			if(_object_arr.event4 =='invoice'){

				invoice_listen();							//当事件4为发票，则使用发票方法


			}

			if(_object_arr.event5 =='remark'){


				remark_listen();							//当事件5为备注，则使用备注方法

			}


			if(_object_arr.event7 =='payondelivery'){

				payondelivery_listen2();						//当事件7为配送时间，则使用配送时间方法
			}
			
		}

        if (is_orderingretail_store == 1)
        {
            choose_send_way_listen();
        } else {
            take_theirself_storge_listen();						//事件2：门店自提或选择快递自动监听
        }

		/*if(_object_arr.event7 =='payondelivery'){

			payondelivery_listen();						//当事件7为配送时间，则使用配送时间方法
		}*/

		//sum_all_money();									//计算总金额
	}

	function payondelivery_listen()
	{

		$(".payondelivery").click(function(){
			var delivery = $(this).attr("open_val");
			if(delivery == 1)
			{
				btn_off($(this));
				delivery = 0;
				$(".mendian").slideDown('fast');
				$(".mendian").next('.line').css('display','block');
				$(".new_pay span").html("立即支付");
			}
			else
			{
				btn_on($(this));
				var obj = $(this);
				delivery = 1;
				$(".mendian").slideUp('fast');
				$(".mendian").next('.line').css('display','none');
				$(".new_pay span").html("立即下单");
				is_take_theirself = 0;
				is_express = 1;
				envent_object_arr.event2 = 'express';
				var temp = [-1,-1,''];

				for(var i=0;i<buy_pid_arr.length;i++)
				{
					console.log("#pid_"+buy_pid_arr[i]+" .center-content span");
					if(is_express_arr[i] == -1)
					{

						$("#pid_"+buy_pid_arr[i]).next('.white-list').find(" .center-content span").text("无配送方式");
					}

					if(is_express_arr[i] == 0)
					{
						$("#pid_"+buy_pid_arr[i]).next('.white-list').find(" .center-content span").text("免邮");
					}
				}
				var store_object_arr = temp;
				var store_object_arr = JSON.stringify(store_object_arr);			//转JSON
				localStorage.setItem('store_'+user_id,store_object_arr);
			}



			localStorage.setItem('payondelivery_'+user_id,delivery);	//存入localStorage

			var event_arr_json = JSON.stringify(envent_object_arr);			//转JSON
			localStorage.setItem('envent_'+user_id,event_arr_json);			//初始化被动事件存入localStorage

		});

		var thiss    = $(".payondelivery");
		var delivery = localStorage.getItem('payondelivery_'+user_id);
		if(delivery == 1)
		{
			btn_on(thiss);
			$(".mendian").slideUp('fast');
			$(".mendian").next('.line').css('display','none');
			$(".new_pay span").html("立即下单");
			is_take_theirself = 0;
			is_express = 1;
			envent_object_arr.event2 = 'express';
			var temp = [-1,-1,''];
			for(var i=0;i<buy_pid_arr.length;i++)
			{
				console.log("#pid_"+buy_pid_arr[i]+" .center-content span");
				if(is_express_arr[i] == -1)
				{

					$("#pid_"+buy_pid_arr[i]).next('.white-list').find(" .center-content span").text("无配送方式");
				}

				if(is_express_arr[i] == 0)
				{
					$("#pid_"+buy_pid_arr[i]).next('.white-list').find(" .center-content span").text("免邮");
				}
			}
			var store_object_arr = temp;
			var store_object_arr = JSON.stringify(store_object_arr);			//转JSON
			localStorage.setItem('store_'+user_id,store_object_arr);
		}
		else if(delivery == 0)
		{
			btn_off($(this));
			$(".mendian").slideDown('fast');
			$(".mendian").next('.line').css('display','block');
			$(".new_pay span").html("立即支付");
		}

		var event_arr_json = JSON.stringify(envent_object_arr);			//转JSON
		localStorage.setItem('envent_'+user_id,event_arr_json);			//初始化被动事件存入localStorage
	}


	function select_payondelivery(){

		$(".payondelivery").click(function(){
			var delivery = $(this).attr("open_val");
			if(delivery == 1){					//关闭
				payondelivery_sel_buss(0);

			}else{								//开启
				payondelivery_sel_buss(1);

			}

		});


	}


	function payondelivery_listen2(){

		var thiss    = $(".payondelivery");
		var delivery = localStorage.getItem('payondelivery_'+user_id);
		if(thiss.length>0){

			if(delivery == 1){

				payondelivery_sel_buss(1);

			}else{

				payondelivery_sel_buss(0);

			}

		}else{
			console.log('没有货到付款');
		}

	}

	//货到付款业务
	function payondelivery_sel_buss(type){

		var thiss    = $(".payondelivery");
		if(type == 0){		//关

				btn_off(thiss);
				$(".mendian").slideDown('fast');
				$(".mendian").next('.line').css('display','block');
				$(".new_pay span").html("立即支付");

				ispay_on = 0;
				envent_object_arr.event7 = '';





		}else{				//开
				btn_on(thiss);
				$(".mendian").slideUp('fast');
				$(".mendian").next('.line').css('display','none');
				$(".new_pay span").html("立即下单");

				$.each($('.itemMainDiv'),function(){
					console.log($(this));
					var is_express = $(this).attr('save_is_express');  //-1表示无配送方式，0表示有配送方式,is_express会被改变不适用
					console.log(is_express);
					var sum_express_supply = $(this).parents('.itemWrapper').find('.sum_express_supply').val();
					var show_span = $(this).parents('.itemWrapper').find('.express-type>.center-content>span');
					console.log(show_span);
					if(is_express == -1){
						show_span.text('无配送方式');
					}else{
						if(sum_express_supply == 0){
							show_span.text('免邮');
						}else{
							show_span.text('快递<?php if(OOF_P != 2) echo OOF_S ?>'+sum_express_supply + '<?php if(OOF_P == 2) echo OOF_S ?>');
						}
					}
				});

				ispay_on = 1;

				/*排斥门店事件，改为快递事件*/
				is_take_theirself = 0;
				is_express = 1;

				envent_object_arr.event7 = 'payondelivery';
				envent_object_arr.event2 = 'express';

				var _store = [];
				$.each($('#resultData .itemWrapper'),function(k,val){

					var self_supply_id =  $(this).attr('supply_id');
					var ii = $(this).attr('ii');
					_store[ii] = [self_supply_id,-1,''];

				});
				var store_object_arr = JSON.stringify(_store);
				localStorage.setItem('store_'+user_id,store_object_arr);

				/*排斥门店事件，改为快递事件*/
		}

			//保存数据
			localStorage.setItem('payondelivery_'+user_id,ispay_on);


			//保存事件
			var event_arr_json = JSON.stringify(envent_object_arr);			//转JSON
			console.log(envent_object_arr);
			localStorage.setItem('envent_'+user_id,event_arr_json);			//初始化被动事件存入localStorage

	}

	//计算总金额
	function sum_all_money(){
		//根据规则计算金额，列举出所有事件的计算方法


		if(order_debug){		//调试参数

			var data = {};

			//触发事件参数
			var _a = new Array();
			_a['card_discount_money']   = card_discount_money;
			_a['coupon_money'] 			= coupon_money;
			_a['user_curr_money'] 		= user_curr_money;

			data.data = _a;
			//触发事件
			var _b = new Array();
			_b['is_select_card']		 = is_select_card;
			_b['is_select_coupon']		 = is_select_coupon;
			_b['is_take_theirself'] 	 = is_take_theirself;
			_b['is_express'] 			 = is_express;
			_b['is_curr'] 				 = is_curr;
			_b['ispay_on'] 				 = ispay_on;

			data.event = _b;

			console.log(envent_object_arr);
			console.log('必填信息本地存储：'+localStorage.getItem('info_'+user_id));
			console.log('配送方式本地存储：'+localStorage.getItem('send_way_'+user_id));
			console.log('门店本地存储：'+localStorage.getItem('store_'+user_id));
			console.log('购物币本地存储：'+localStorage.getItem('curr_'+user_id));
			console.log('优惠券本地存储：'+localStorage.getItem('coupon_'+user_id));
			console.log('发票本地存储：'+localStorage.getItem('invoice_'+user_id));
			console.log('备注本地存储：'+localStorage.getItem('remark_'+user_id));
			console.log('货到付款本地存储：'+localStorage.getItem('payondelivery_'+user_id));
			console.log(data);


		}


		//互斥事件1

		//选择会员卡与优惠券互斥监听
		var envent_res1 = 0;		//事件1金额
		if(is_select_card ==1){

			var select_discount = parseFloat('<?php echo $discount ;?>');
            envent_res1 = card_discount_money;
            // 满赠活动
			platform_exchange_envent_res1 = platform_exchange_card;

		}
		if(is_select_coupon ==1){


			envent_res1 = coupon_money;				//选择的优惠券优惠金额
            // 满赠活动
            platform_exchange_envent_res1 = platform_exchange_coupon;
		}

		//互斥事件2
		//选择自提与使用快递互斥监听

		var envent_res2 =0;			//事件2金额
		if(is_take_theirself ==1 ){					//自提
			//is_express = 0;
			//统计总运费
			var sum_supply_express = 0;
			$.each($('.sum_express_supply'),function(){
				var is_theirself = $(this).parent().find('.is_theirself').val();

				if(is_theirself==0){
					var supply_express = $(this).val();
					sum_supply_express += parseFloat(supply_express);
				}

			});
			$('#sum_express').attr('sum_express',sum_supply_express).text('+<?php if(OOF_P != 2) echo OOF_S ?>'+sum_supply_express+'<?php if(OOF_P == 2) echo OOF_S ?>');


			envent_res2 = sum_supply_express;
		}
		if(is_express == 1){						//运费
			//is_take_theirself = 0;
			//统计总运费
			var sum_supply_express = 0;
			$.each($('.sum_express_supply'),function(){
				var is_theirself = $(this).parent().find('.is_theirself').val();
				if(is_theirself==0){
					var supply_express = $(this).val();
					sum_supply_express += parseFloat(supply_express);
				}

			});
			//$('#sum_express').attr('sum_express',sum_supply_express).text('+￥'+sum_supply_express);
			$('#sum_express').attr('sum_express',sum_supply_express).text('+<?php if(OOF_P != 2) echo OOF_S ?>'+sum_supply_express+'<?php if(OOF_P == 2) echo OOF_S ?>');


			envent_res2 = sum_supply_express;
		}


		//使用购物币
		var envent_res3 = 0;		//事件3金额
        //console.log(is_curr);
        //console.log(is_curr.length);
		if(is_curr_count >0){
            //console.log(is_curr);
			//envent_res3 = '扣除购物币的金额';
            envent_res3 = user_curr_money;
			if( is_check_password == 1 ){
                platform_exchange_envent_res3 = parseFloat($('#user_currency_-1').val());
            }
		}






			//节省金额 = 事件1金额
			var save_money = parseFloat(envent_res1);

            //购物币抵扣金额 = 事件3金额
            var curr_money = parseFloat(envent_res3);

			//复购抵扣金额 = 事件4金额
			var deductible_money = 0;
			//是否开启店铺奖励抵扣

			if(is_shop_deductible){
				var sum_shop_reward = $('.sum_shop_reward').attr('val');
				 sum_shop_reward_en = $('.sum_shop_reward').val();
                deductible_money += parseFloat(sum_shop_reward);
                //满赠活动 平台抵扣价格
				platform_exchange_deductible_money += parseFloat(platform_self_reward);
				console.log(deductible_money);
			}
			//是否开启3级奖励抵扣

			if(is_extension_deductible){
				var sum_self_reward = $('.sum_self_reward').attr('val');
				 sum_self_reward_en = $('.sum_self_reward').val();
				deductible_money += parseFloat(sum_self_reward);
                //满赠活动 平台抵扣价格
                platform_exchange_deductible_money += parseFloat(platform_shop_reward);
				console.log(sum_self_reward_en);
			}

        // 满赠活动 平台总抵扣
        platform_exchange = parseFloat(platform_exchange_envent_res1) + parseFloat(platform_exchange_envent_res3) + parseFloat(platform_exchange_deductible_money)
		platform_final_price = parseFloat(platform_price_no_exchange) - parseFloat(platform_exchange)
        if( parseFloat(max_threshold) > parseFloat(platform_final_price) ){
            showAlertMsgNoclose('提示','金额不满足满赠条件!','知道了',function(){
                location.href = '/weixinpl/mshop/order_form.php?platform_price='+platform_final_price;
            })
        }

        if(!isNaN(platform_final_price))
        {	
	        $.ajax({
	            url:'/mshop/admin/index.php?m=exchange&a=get_fist_exchange_detail&price='+platform_final_price,
	            async: false,
	            dataType: 'json',
	            success:function(data){
	                if( data.data.threshold > 0 ){
	                    $('#exchange_threshold').text(data.data.threshold)
	                    $('#exchange_num').text(data.data.count_ex_str)
	                }else{
	                    $('.full-shop').hide()
	                }
	            }
	        });
	    }    

			//运费金额 = 事件2金额
			var add_money = parseFloat(envent_res2);

			//当有税收则加入运费金额
			var sum_tax = 0;
			<?php if($all_tax_total>0){?>

				sum_tax = parseFloat('<?php echo $all_tax_total;?>');

			<?php }?>

			//产品金额
			var sum_price = $('#sum_price').attr('sum_price');				//订单总价

			put_sum_data_to_html(sum_price,save_money,curr_money,add_money,sum_tax,deductible_money);			//将结果赋值到html上





	}

	function get_money_ex_express(val){
        money_ex_express = val;
    }


	/*计算订单金额，并把其他数据加载到html上面*/



	function put_sum_data_to_html(sum_price,save_money,curr_money,sum_express,sum_tax,deductible_money){

		//最终金额 = 产品原价 + 运费 - 优惠金额
		var sum_price = parseFloat(sum_price);
		var save_money = parseFloat(save_money).toFixed(2);
        var curr_money = parseFloat(curr_money).toFixed(2);
        var deductible_money = parseFloat(deductible_money).toFixed(2);
		var sum_express = parseFloat(sum_express);


		var final_money = sum_price  + sum_express + sum_tax - save_money - curr_money - deductible_money;
        console.log(sum_price,sum_express,sum_tax,save_money,curr_money,deductible_money)
		if(final_money<0){
			save_money = sum_price  + sum_express + sum_tax - curr_money - deductible_money;
			final_money = 0;
		}
			final_money = final_money.toFixed(2)
		$('#save_money').attr('save_money',save_money).text('-<?php if(OOF_P != 2) echo OOF_S ?>'+save_money+'<?php if(OOF_P == 2) echo OOF_S ?>');



	   $('#curr_money').attr('curr_money',curr_money).text('-<?php if(OOF_P != 2) echo OOF_S ?>'+curr_money+'<?php if(OOF_P == 2) echo OOF_S ?>');
		$('#sum_express').attr('sum_express',sum_express).text('+<?php if(OOF_P != 2) echo OOF_S ?>'+sum_express+'<?php if(OOF_P == 2) echo OOF_S ?>');
		if(sum_tax>0){
			$('#sum_tax').attr('sum_tax',sum_tax).text('+<?php if(OOF_P != 2) echo OOF_S ?>'+sum_tax+'<?php if(OOF_P == 2) echo OOF_S ?>');
		}
		$('#sum_all_money').attr('sum_all_money',final_money).text('<?php if(OOF_P != 2) echo OOF_S ?>'+final_money+'<?php if(OOF_P == 2) echo OOF_S ?>');


        var money_ex_express = final_money;
        get_money_ex_express(money_ex_express);

		if(edit_type == 1){		//记录每一次修改后的金额，除了购物币
				$('#sum_all_money').attr('temp_sum_all_money',final_money);
			}
	}

	/*计算订单金额，并把其他数据加载到html上面*/


	/************************互斥事件区域***********************/



	/******互斥事件1:会员卡折扣与优惠券*******/


	//监听选择会员卡折扣  暂时不用
	/*function select_card_old(){

		var select_card_id = parseFloat('<?php echo $select_card_id?>');			//选择的会员卡ID
		var select_card_remain = parseFloat('<?php echo $rtn_card_array[0]?>');		//选择的会员卡余额
		var select_card_score = parseFloat('<?php echo $rtn_card_array[1]?>');		//选择的会员卡积分
		var select_discount = parseFloat('<?php echo $rtn_card_array[2]?>');			//选择的会员卡折扣

		if(select_card_id>0 &&(select_discount>0 && select_discount<100)){

			//选择会员卡折扣标识置1
			is_select_card = 1;


			//var save_money =  parseFloat($('#sum_price').attr('sum_price')) * parseFloat((100 - select_discount)/100);

			//$('#save_money').attr('save_money',save_money.toFixed(2));


		}else{
			is_select_card = 0;
		}
	}*/


	//选择会员卡折扣
	function select_card(){


		$(".open_card").click(function(){
			//点击会员卡折扣事件
			console.log(envent_object_arr);
			//-----获取产品金额，优惠金额，运费
			var sum_price = parseFloat($('#sum_price').attr('sum_price'));			//产品金额

			var sum_express = parseFloat($('#sum_express').attr('sum_express'));	//产品的邮费

			//-----获取产品金额，优惠金额，运费

			var open_val = $(this).attr('open_val');

            //重置购物币抵扣开始
            envent_object_arr.event3 = '';//清空购物币事件
            is_curr_count = 0;// 购物币已开数置零
            $.each($('.open_curr'),function(){
                var supply_id = $(this).attr('supply_id');
                if($(this).attr('open_val')==1){
                    is_curr[supply_id] = 0;
                    del_curr_product(supply_id);//清空本地储存
                    btn_off($(this));
                    $('#user_currency_'+supply_id).val('');//清空用户输入的购物币
                    $('.currency_'+supply_id).hide();	//不使用购物币
                }
            });
            user_curr_money = 0;//使用购物币清零
            sum_all_money();
            //重置购物币抵扣结束


			if(open_val ==0 ){								//开启会员卡折扣
				is_select_card = 1;
				$('.card').show();							//限制会员卡折扣信息
				btn_on($(this));							//按钮显示ON 状态

				//----计算实际金额
				var select_discount = parseFloat('<?php echo $discount ;?>');

				var save_card =  parseFloat($('#sum_price').attr('sum_price')) * parseFloat((100 - select_discount)/100);
				card_discount_money = save_card;		//赋值给折扣金额
                // 满赠活动
                platform_exchange_card = parseFloat(platform_price) * parseFloat((100 - select_discount)/100); //赋值给折扣金额(平台商品)

				//打折后最少金额为0.01
				if(card_discount_money<0.01){
					card_discount_money=0;
                    platform_exchange_card=0;
				}

                /* 更新购物币可抵扣金额 */
                $.each($('.open_curr'),function(){
                    var supply_id = $(this).attr('supply_id');
                    var supply_currency = curr_arr_json[supply_id];

                    //zhou 开启折扣后获取折扣后的可抵扣购物币
                    //var supply_currency = curr_arr_json['discount'][supply_id];

                    // 拼团开启后，拼团的购物币抵购比例     2018.1.22
                    var supply_currency_collage_product_card = '';
                    if(if_bbt==0){
                        if(is_collage_product && group_buy_type == 2){
                            if(shopcode_onoff==1 && (shopcode_limit==3 || (shopcode_limit==1 && group_id<0)|| (shopcode_limit==2 && group_id>0))){
                                    supply_currency_collage_product_card = Math.floor(sum_price*shopcode_precent*0.01*100)/100;
                                    supply_currency_collage_product_card = supply_currency_collage_product_card.toFixed(2);  

                                    // if(parseFloat(supply_currency_collage_product_card) < parseFloat(supply_currency)){
                                        //拼团的购物币抵购小于用户购物币抵购的数量时
                                    supply_currency = supply_currency_collage_product_card;
                                    // }
                                }                         
                        }       
                    }

                    //供应商使用折扣后的金额
                    var sum_price_supply = $('#sum_price_supply_'+supply_id).val();
                    var discount_sum_price_supply = sum_price_supply * parseFloat(select_discount/100);
                    //可抵扣金额取两者中的最小值
                    if(parseFloat(supply_currency) > parseFloat(discount_sum_price_supply)){
                        var new_currency = discount_sum_price_supply;
                    }else{
                        var new_currency = supply_currency;
                    }
                    //var new_currency = supply_currency * parseFloat(select_discount/100);
                    //new_currency = new_currency.toFixed(2);
                    //保留两位小数，不四舍五入
                    var curr_string = new_currency.toString();
                    var point = curr_string.indexOf('.');//点的位置
                    var cut_strat = 0;//截取开始位置
                    if(point>0){//有小数点才截取
                        var cut_end = point+3;//截取结束位置
                        new_currency = Number(curr_string.substring(cut_strat,cut_end));
                    }
                    $('#deductible_curr_'+supply_id).html(new_currency);
                });



				//优惠券互斥处理
				is_select_coupon = 0;


				$('.select_coupon_span_r').hide();								//隐藏优惠券信息

				envent_object_arr.event1 = 'card';								//把事件1修改为'card',存入本地存储

				var event_arr_json = JSON.stringify(envent_object_arr);			//转JSON

				localStorage.setItem('envent_'+user_id,event_arr_json);			//初始化被动事件存入localStorage


				sum_all_money();						//----计算实际金额

			}else{											//关闭会员卡折扣
                platform_exchange_card = 0
                $('#user_currency_-1').trigger('input')
                /* 更新购物币可抵扣金额 */
                $.each($('.open_curr'),function(){
                    var supply_id = $(this).attr('supply_id');
                    var supply_currency = curr_arr_json[supply_id];

                    // 拼团开启后，拼团的购物币抵购比例     2018.1.22
                    var supply_currency_collage_product_card = '';
                    if(if_bbt==0){
                        if(is_collage_product && group_buy_type == 2){
                            if(shopcode_onoff==1 && (shopcode_limit==3 || (shopcode_limit==1 && group_id<0)|| (shopcode_limit==2 && group_id>0))){
                                    supply_currency_collage_product_card = Math.floor(sum_price*shopcode_precent*0.01*100)/100;
                                    supply_currency_collage_product_card = supply_currency_collage_product_card.toFixed(2);  

                                    // if(parseFloat(supply_currency_collage_product_card) < parseFloat(supply_currency)){
                                        //拼团的购物币抵购小于用户购物币抵购的数量时
                                    supply_currency = supply_currency_collage_product_card;
                                    // }
                                }                         
                        }       
                    }

                    $('#deductible_curr_'+supply_id).html(supply_currency);
                });

				is_select_card = 0;
				envent_object_arr.event1 = '';
				card_discount_money = 0;					//赋值给折扣金额
				sum_all_money();							//重新计算价格

				$('.card').hide();							//隐藏会员卡折扣信息
				btn_off($(this));							//按钮显示ON 状态


			}
				var event_arr_json = JSON.stringify(envent_object_arr);			//转JSON

				//console.log(event_arr_json);
				localStorage.setItem('envent_'+user_id,event_arr_json);			//初始化被动事件存入localStorage
		});


	}


	//会员卡折扣监听处理
	function select_card_listen(){

			is_select_card = 1;
			$('.card').show();							//限制会员卡折扣信息
			btn_on($(".open_card"));							//按钮显示ON 状态

			//----计算实际金额
			var select_discount = parseFloat('<?php echo $discount ;?>');

			var save_card =  parseFloat($('#sum_price').attr('sum_price')) * parseFloat((100 - select_discount)/100);

			card_discount_money = save_card;		//赋值给折扣金额
			//打折后最少金额为0.01
			if(card_discount_money<0.01){
					card_discount_money=0;
			}

			/* 更新购物币可抵扣金额 */
            $.each($('.open_curr'),function(){
                var supply_id = $(this).attr('supply_id');
                var supply_currency = curr_arr_json[supply_id];

                //zhou 开启折扣后获取折扣后的可抵扣购物币
                //var supply_currency = curr_arr_json['discount'][supply_id];

                    // 拼团开启后，拼团的购物币抵购比例     2018.1.22
                    var supply_currency_collage_product_card = '';
                    if(if_bbt==0){
                        if(is_collage_product && group_buy_type == 2){
                            if(shopcode_onoff==1 && (shopcode_limit==3 || (shopcode_limit==1 && group_id<0)|| (shopcode_limit==2 && group_id>0))){
                                    supply_currency_collage_product_card = Math.floor(sum_price*shopcode_precent*0.01*100)/100;
                                    supply_currency_collage_product_card = supply_currency_collage_product_card.toFixed(2);  

                                    // if(parseFloat(supply_currency_collage_product_card) < parseFloat(supply_currency)){
                                        //拼团的购物币抵购小于用户购物币抵购的数量时
                                    supply_currency = supply_currency_collage_product_card;
                                    // }
                                }                         
                        }       
                    }

                //供应商使用折扣后的金额
                var sum_price_supply = $('#sum_price_supply_'+supply_id).val();
                var discount_sum_price_supply = sum_price_supply * parseFloat(select_discount/100);
                //可抵扣金额取两者中的最小值
                if(parseFloat(supply_currency) > parseFloat(discount_sum_price_supply)){
                    var new_currency = discount_sum_price_supply;
                }else{
                    var new_currency = supply_currency;
                }
                //var new_currency = supply_currency * parseFloat(select_discount/100);
                //new_currency = new_currency.toFixed(2);
                //保留两位小数，不四舍五入
                var curr_string = new_currency.toString();
                var point = curr_string.indexOf('.');//点的位置
                var cut_strat = 0;//截取开始位置
                if(point>0){//有小数点才截取
                    var cut_end = point+3;//截取结束位置
                    new_currency = Number(curr_string.substring(cut_strat,cut_end));
                }
                $('#deductible_curr_'+supply_id).html(new_currency);
            });


			//优惠券互斥处理
			is_select_coupon = 0;
			clear_coupon();

			$('.select_coupon_span_r').hide();			//隐藏优惠券信息

	}





	//优惠券监听处理
	function select_coupon_listen(){

		var sum_price = $('#sum_price').attr('sum_price');				//订单总价
		var sum_express = $('#sum_express').attr('sum_express');		//订单运费

		var coupon_object = localStorage.getItem('coupon_'+user_id); 	//读取localStorage的数据

		var coupon_object_arr = JSON.parse(coupon_object);				//json转数组

		if(coupon_object == null || coupon_object == ''){

		}else{

			$.each(coupon_object_arr,function(i,value){
				if(value == null || value == ''){
					return ;		//contiune的作用
				}
				var select_coupon_id 	= value[0];				//选择的优惠券ID
				var NeedMoney 		 	= value[1];				//选择的优惠券金额限制
				var money 				= value[2];				//选择的优惠券优惠金额
				var coupon_supply_id 	= value[3];				//选择的优惠券优惠金额
				var class_type 			= value[5];				//选择的优惠券的类型

				$.each($('#resultData .itemWrapper'),function(k,val){
					var self_supply_id =  $(this).attr('supply_id');
					if(select_coupon_id>0 && NeedMoney<=sum_price ){//当选择了优惠券且优惠券使用金额限制小于订单总价，才能使用优惠券
						if(coupon_supply_id==self_supply_id){
							//选择优惠券标识置1
							is_select_coupon = 1;
							coupon_money	+=	money;	//重新赋值给优惠券金额
                            // 满赠活动(优惠券金额)
                            if( self_supply_id == -1 ){
                                platform_exchange_coupon = parseFloat(platform_exchange_coupon) + parseFloat(money);
                            }
							//sum_all_money();			//重新计算价格
							if( class_type == 3 ){
								coupon_money = parseFloat(sum_price);
                                platform_exchange_coupon = parseFloat(sum_price);
								$(this).find('.select_coupon_span_r').text('(团长免单)');
							} else {
								if(NeedMoney==-1){
									$(this).find('.select_coupon_span_r').text('(当前优惠券优惠'+money+'<?php echo OOF_T ?>)');
								}else{
									$(this).find('.select_coupon_span_r').text('(满'+NeedMoney+'<?php echo OOF_T ?>优惠'+money+'<?php echo OOF_T ?>)');
								}
							}
                            //console.log(buy_all_data_json[self_supply_id]);
							var supply_currency = curr_arr_json[self_supply_id];

							// 拼团开启后，拼团的购物币抵购比例     2018.1.22
                            var supply_currency_collage_product_coupon = '';
                            if(if_bbt==0){
                                if(is_collage_product && group_buy_type == 2){
                                    if(shopcode_onoff==1 && (shopcode_limit==3 || (shopcode_limit==1 && group_id<0)|| (shopcode_limit==2 && group_id>0))){
                                            supply_currency_collage_product_coupon = Math.floor(sum_price*shopcode_precent*0.01*100)/100;
                                            supply_currency_collage_product_coupon = supply_currency_collage_product_coupon.toFixed(2);  

                                            // if(parseFloat(supply_currency_collage_product_coupon) < parseFloat(supply_currency)){
                                            //拼团的购物币抵购小于用户购物币抵购的数量时
                                            supply_currency = supply_currency_collage_product_coupon;
                                            // }
                                    }                         
                                }       
                            }

                            //供应商使用优惠券后的金额
                            var sum_price_supply = $('#sum_price_supply_'+self_supply_id).val();
                            var coupon_sum_price_supply = sum_price_supply - money;
                            //可抵扣金额取两者中的最小值
                            if(parseFloat(supply_currency) > parseFloat(coupon_sum_price_supply)){
                                var new_currency = coupon_sum_price_supply;
                            }else{
                                var new_currency = supply_currency;
                            }
                            //var new_currency = supply_currency-money;
                            if(new_currency<0){
                                new_currency = 0;
                            }
                            //new_currency = new_currency.toFixed(2);
                            //保留两位小数，不四舍五入
                            var curr_string = new_currency.toString();
                            var point = curr_string.indexOf('.');//点的位置
                            var cut_strat = 0;//截取开始位置
                            if(point>0){//有小数点才截取
                                var cut_end = point+3;//截取结束位置
                                new_currency = Number(curr_string.substring(cut_strat,cut_end));
                            }
                            $('#deductible_curr_'+self_supply_id).html(new_currency);
							//$(this).find('.select_coupon_id').val(select_coupon_id);
							//同商家购物币互斥

							is_ban_currency[self_supply_id] = 1;

						}

					}

				});
				//隐藏会员卡折扣
				$('.card').hide();

				//----关闭会员折扣开关
				btn_off($('.open_card'));
				//会员卡折扣互斥操作
				is_select_card	= 0;

			});


		}
	}

	/******互斥事件1:会员卡折扣与优惠券*******/



	/******互斥事件2：自提与使用快递*******/

	var express_type = 0;//用来判断是否未门店自提，是为1，否为0;
	//监听门店的本地存储
	function take_theirself_storge_listen(){

		var store_object = localStorage.getItem('store_'+user_id); 	//读取localStorage的数据
		console.log(store_object);
		var store_object_arr = JSON.parse(store_object);			//json转数组


		var j = 0;

		if(store_object == null || store_object == ''){

		}else{

			$.each(store_object_arr,function(i,value){

				if(value == null || value == ''){
					return ;		//contiune的作用
				}
				var store_supply_id 	= value[0];
				var store_id 			= value[1];
				var default_name 		= value[2];



				//遍历每个供应商的产品
				$.each($('#resultData .itemWrapper'),function(k,val){
					var thiss = $(this);

					var self_supply_id =  thiss.attr('supply_id');

                   var test1 =  thiss.find('.store').attr('supply_id');
					if(store_supply_id == self_supply_id){			//找到用户每个供应商对应选择的的门店
						if(store_id != -1){
                           	//修改使用门店标识
							thiss.find('.store').find('.left-title').css('width','60%');
							thiss.find('.store').find('.left-title >span').text('已选择的门店：');
							thiss.find('.store').find('.left-title > .select_store_span_r').text(default_name);

							thiss.find('.express-type >.center-content span').text('门店自提');
                            express_type = 1;
							//修改价格
							var sum_price_supply = thiss.find('.sum_price_supply').val();
							
							var strs = "<?php if(OOF_P != 2) echo OOF_S ?>"+sum_price_supply+"<?php if(OOF_P == 2) echo OOF_S ?>";
							
							thiss.find('.span3 .express_span').text(strs);


							//选择门店不考虑无配送方式

							thiss.find('.itemMainDiv').attr('is_express',0);
							thiss.find('.is_theirself').val(1);


							j++;
						}

					}

				});

			});
			if(j >0){	//假如门店存储不为空且选择了门店，则使用自提计算运费
				//排斥货到付款事件
				payondelivery_sel_buss(0);
				is_take_theirself = 1;
				is_express = 0;
				envent_object_arr.event2 = 'take_theirself';

			}else{

				is_take_theirself = 0;
				is_express = 1;
				envent_object_arr.event2 = 'express';

			}

			var event_arr_json = JSON.stringify(envent_object_arr);			//转JSON

			localStorage.setItem('envent_'+user_id,event_arr_json);			//初始化被动事件存入localStorage

		}

	}



	/******互斥事件2：自提与使用快递*******/
	function choose_send_way_listen(){
		var store_object = localStorage.getItem('orderingretail_store_'+user_id); 	//读取localStorage的数据
		console.log(store_object);
		var store_object_arr = JSON.parse(store_object);			//json转数组


		var j = 0;

		if(store_object == null || store_object == ''){

		}else{

			$.each(store_object_arr,function(i,value){

				if(value == null || value == ''){
					return ;		//contiune的作用
				}
				var store_supply_id 	= value[0]; //供应商id
				var store_id 			= value[1]; //门店id
				var branch_id 			= value[2]; //子门店id
				var default_name 		= value[3]; //门店名
				var send_way 		    = value[4]; //配送方式 1：快递，2:自提
                if(branch_id>-1){
                    //$(".send_way").removeAttr('onclick');
                    $(".send_way").attr("onclick","alert_shop_branch()");
                }
				console.log(value);

				//遍历每个供应商的产品
				$.each($('#resultData .itemWrapper'),function(k,val){
					var thiss = $(this);

					var self_supply_id =  thiss.attr('supply_id');

                   var test1 =  thiss.find('.orderingretail_store').attr('supply_id');
					if(store_supply_id == self_supply_id){			//找到用户每个供应商对应选择的的门店
						if(store_id != -1 || branch_id!=-1){
                           	//修改使用门店标识
							thiss.find('.orderingretail_store').find('.left-title').css('width','60%');
							thiss.find('.orderingretail_store').find('.left-title > .select_store_span_r').text(default_name);

                            //修改价格
							var sum_price_supply = thiss.find('.sum_price_supply').val();

							thiss.find('.list-one-right >.span3.express_span ').text('<?php if(OOF_P != 2) echo OOF_S ?>'+sum_price_supply+'<?php if(OOF_P == 2) echo OOF_S ?>');

							j++;
						}
                        if (send_way == 2)
                        {
                            thiss.find('.express-type >.center-content span').text('门店自提');
                            thiss.find('.itemMainDiv').attr('is_express',0);
                            is_express = 0;
                        } else if (send_way == 1) {
                            is_express = 1;


                            var sum_express_supply = $(".sum_express_supply").val()
                            sum_price_supply = parseFloat(sum_price_supply) + parseFloat(sum_express_supply);
                            thiss.find('.list-one-right .span3 span.express_span ').html('<?php if(OOF_P != 2) echo OOF_S ?>'+sum_price_supply+'<?php if(OOF_P == 2) echo OOF_S ?>');
                        }

					}

				});

			});

		}
	}

	//子门店选择配送方式消息提示
    function alert_shop_branch(){
        alert_warning('该门店仅支持自提，请更改门店！');
    }

	/******互斥事件3：使用购物币*******/

	//点击购物币事件
	function select_curr(){

		$(".open_curr").click(function(){

			var open_val = $(this).attr('open_val');
            var supply_id = $(this).attr('supply_id');
            $(".close_sid").val(supply_id);
            //console.log(product_id);

            var sum_use_currency    = 0;       //已填购物币数额
            $(".user_currency").each(function(){
                var supply_id2 = $(this).attr('supply_id');
                if(supply_id2!=supply_id){
                if(is_curr[supply_id2]){
                    this_currency = $(this).val();
                    if(this_currency==null || this_currency==''){
                        this_currency = 0;
                    }
                    sum_use_currency += parseFloat(this_currency);
                }
                }

            });

            //购物币余额
			var max_curr = <?php echo $user_currency;?>;
            max_curr = parseFloat(max_curr) - parseFloat(sum_use_currency);

            console.log(max_curr);
            //可抵扣购物币
            var supply_currency = curr_arr_json[supply_id];
            console.log(supply_currency);

            // 拼团开启后，拼团的购物币抵购比例     2018.1.22
            var supply_currency_collage_product = '';
            if(if_bbt==0){
                if(is_collage_product && group_buy_type == 2){
                    if(shopcode_onoff==1 && (shopcode_limit==3 || (shopcode_limit==1 && group_id<0)|| (shopcode_limit==2 && group_id>0))){
                            supply_currency_collage_product = Math.floor(sum_price*shopcode_precent*0.01*100)/100;
                            supply_currency_collage_product = supply_currency_collage_product.toFixed(2);  

                            // if(parseFloat(supply_currency_collage_product) < parseFloat(supply_currency)){
                                //拼团的购物币抵购小于用户购物币抵购的数量时
                                supply_currency = supply_currency_collage_product;
                            // }
                    }                         
                }
            }

            console.log(supply_currency_collage_product);
            console.log(supply_currency);
            
            //判断会员卡折扣
            if(is_select_card == 1){
                //var select_discount = parseFloat('<?php echo $discount ;?>');
                //var supply_currency = supply_currency * parseFloat(select_discount/100);
                //supply_currency = supply_currency.toFixed(2);
                //保留两位小数，不四舍五入
                //supply_currency = Number(supply_currency.toString().substring(0,supply_currency.toString().indexOf('.')+3));
                var supply_currency = parseFloat($('#deductible_curr_'+supply_id).html());
            }
            //判断优惠券
            if(is_select_coupon == 1){
                var supply_currency = parseFloat($('#deductible_curr_'+supply_id).html());
            }

            if(max_curr>supply_currency){
                var show_curr = supply_currency;
            }else{
            	//显示的价格应减去复购的
                var show_curr = max_curr;
            }
            //zhou
            show_curr = show_curr-parseFloat(sum_self_newreward)
  			if(show_curr < 0)
  			{
  				show_curr = 0
  			}

			if(open_val ==0 ){

				if( is_ban_currency[supply_id] == 1 && is_ban_use_coupon_currency == 1 ){
					alertAutoClose('购物币和优惠券不能同时使用',2000);
				}else{
					//is_curr = 1;
		            is_curr[supply_id] = 1;
		            is_curr_count++;
		            //console.log(is_curr_count);
					envent_object_arr.event3 = 'curr';
					btn_on($(this));
					$('.currency_'+supply_id).show();
		            if(is_check_password==0){
						/* 支付密码设置优化 create by hzq */
						<?php $_SESSION['pass_url_'.$customer_id] = '/weixinpl/mshop/order_form.php?customer_id='.$customer_id_en; ?>
						/* 支付密码设置优化 end */
		                check_has_password ();
		            }
					//curr_input_listen();					//监听购物币输入框  这里重复监听了，下面还监听了一次
		            $('#user_currency_'+supply_id).val(show_curr);
		            $('#user_currency_'+supply_id).trigger("input");
		            user_curr_money = get_user_curr_money();
		            sum_all_money();
				}
			}else{
				$('#user_currency_-1').val(0)
                $('#user_currency_-1').trigger('input')
				//is_curr = 0;
                is_curr[supply_id] = 0;
                user_curr_money = get_user_curr_money();
                is_curr_count--;
                //console.log(is_curr_count);
                var sum_ov = 0;
                $.each($('.open_curr'),function(){
                    var ov = $(this).attr('open_val');
                    sum_ov += parseFloat(ov);
                });
                sum_ov = sum_ov - 1;//再减去当前关闭这个开关
                //console.log(sum_ov);
                if(sum_ov==0){
                    //所有购物币开关都关了才清空事件3
                    envent_object_arr.event3 = '';
                }else{
                    envent_object_arr.event3 = 'curr';
                }

                del_curr_product(supply_id);

				btn_off($(this));
				$('#user_currency_'+supply_id).val('');			//清空用户输入的购物币
				$('.currency_'+supply_id).hide();
                $('#user_currency_-1').val(0)
                $('#user_currency_-1').trigger('input')
				//不使用购物币
				sum_all_money();
			}



			var event_arr_json = JSON.stringify(envent_object_arr);			//转JSON

			localStorage.setItem('envent_'+user_id,event_arr_json);			//初始化被动事件存入localStorage

		});


		curr_input_listen();				//跳转页面回来需要自动监听购物币输入框

	}

	function close_currency_btn(){
        var close_sid = $(".close_sid").val();
        $("#open_curr_"+close_sid).click();
    }

	//监听购物币输入框
	function curr_input_listen(){

		$('.user_currency').bind('input propertychange',function(){
            var this_supply_id = $(this).attr('supply_id');
            var sum_use_currency    = 0;       //已填购物币数额

            //遍历购物币输入框
            $(".user_currency").each(function(){
                //获取标识
                var supply_id = $(this).attr('supply_id');
                //不算当前输入框
                if(supply_id!=this_supply_id){
                    //有开启按钮才读取填入的购物币数量
                    if(is_curr[supply_id]){
                        //计算已输入购物币总和
                        //console.log(product_id);
                        this_currency = $(this).val();
                        if(this_currency==null || this_currency==''){
                            this_currency = 0;
                        }
                        sum_use_currency += parseFloat(this_currency);
                    }
                }

            });

			edit_type = 0;	//不更新temp_sum_all_money

            //zhou 购物币余额
			var max_curr = <?php echo $user_currency;?>;
            max_curr = parseFloat(max_curr) - parseFloat(sum_use_currency)-parseFloat(sum_self_newreward);
            if(max_curr < 0)
  			{
  				max_curr = 0
  			}

            //zhou 可抵扣购物币
            var supply_currency = parseFloat(curr_arr_json[this_supply_id])-parseFloat(sum_self_newreward);

            // 拼团开启后，拼团的购物币抵购比例     2018.1.22
            if(if_bbt==0){
                if(is_collage_product && group_buy_type == 2){
                    if(shopcode_onoff==1 && (shopcode_limit==3 || (shopcode_limit==1 && group_id<0)|| (shopcode_limit==2 && group_id>0))){
                            supply_currency_collage_product = Math.floor(sum_price*shopcode_precent*0.01*100)/100;
                            supply_currency_collage_product = supply_currency_collage_product.toFixed(2);  

                            // if(parseFloat(supply_currency_collage_product) < parseFloat(supply_currency)){
                                //拼团的购物币抵购小于用户购物币抵购的数量时
                                supply_currency = supply_currency_collage_product;
                            // }
                    }                         
                }
            }

            console.log(supply_currency);

            if(supply_currency < 0)
  			{
  				supply_currency = 0
  			}
            //判断会员卡折扣
            if(is_select_card == 1){
                //var select_discount = parseFloat('<?php echo $discount ;?>');
                //var supply_currency = supply_currency * parseFloat(select_discount/100);
                //supply_currency = supply_currency.toFixed(2);
                //保留两位小数，不四舍五入
                //supply_currency = Number(supply_currency.toString().substring(0,supply_currency.toString().indexOf('.')+3));
                var supply_currency = parseFloat($('#deductible_curr_'+this_supply_id).html());
            }
            //判断优惠券
            if(is_select_coupon == 1){
                var supply_currency = parseFloat($('#deductible_curr_'+this_supply_id).html());
            }
			//console.log(supply_currency);
            var curr_values = 0;
            if($('#open_curr_'+this_supply_id).attr('open_val')==1) {
                //console.log("333");
                var curr_values = $('#user_currency_'+this_supply_id).val();        //用户输入的购物币
            }

            console.log(curr_values);

			if(curr_values!='' ){
				//console.log("111");
                if(parseFloat(supply_currency) > parseFloat(max_curr)){
                    //可抵用购物币大于购物币余额，跟余额对比
                    if(parseFloat(curr_values) > parseFloat(max_curr)){	//当超出购物币余额

                        curr_error('您输入的购物币超出了您的购物币余额:'+max_curr,this_supply_id);


                        return;
                    }
                }else{
                    //可抵用购物币小于购物币余额，跟可抵用购物币对比
                    if(parseFloat(curr_values) > parseFloat(supply_currency)){	//当超出可抵扣购物币

                        curr_error('您输入的购物币超出了可抵用购物币',this_supply_id);


                        return;
                    }
                }

				/* 新抵用方式无需跟订单金额对比
                if(parseFloat(curr_values) > parseFloat(all_money)){	//当超出订单金额

					//console.log()
					curr_error('您输入的购物币超出订单金额');


					return;
				} */

				//在可用购物币以内，正常使用

                //console.log(curr_values);
                //输入的值是数字，并且大于0才执行以下操作

                //zhou
                curr_values = parseFloat(curr_values)+parseFloat(sum_self_newreward);

                if((!isNaN(curr_values))&&curr_values>=0){
                    user_curr_money = get_user_curr_money();
                    //console.log(user_curr_money);
                    //user_curr_money = user_curr_money + curr_values;
                    if(_Curr==''){
                    //数组空，直接插入

                    var curr_array_temp = new Array(this_supply_id,curr_values);//console.log(curr_array_temp);
                    //_Curr{} = curr_array_temp ;
                    _Curr.push(curr_array_temp);

                    //_Curr[this_supply_id] = curr_values
                    var curr_array_json = JSON.stringify(_Curr);//转JSON

                    //console.log(_Curr);

                    localStorage.setItem('curr_'+user_id,curr_array_json);	//存入localStorage
                    }else{
                        var modify = 0;//1.修改，0.插入
                        $.each(_Curr,function(i,value){
                            if(value[0]==this_supply_id){
                                modify = 1;//已存在，修改
                                return false;
                            }
                        });
                        if(modify==0){
                            var curr_array_temp = new Array(this_supply_id,curr_values);
                            _Curr.push(curr_array_temp);
                            var curr_array_json = JSON.stringify(_Curr);//转JSON
                            localStorage.setItem('curr_'+user_id,curr_array_json);
                        }else{
                            var modify_Curr = new Array();
                            $.each(_Curr,function(i,value){
                                if(value == null || value == ''){
                                    return ;		//contiune的作用
                                }
                                var curr_supply_id 	= value[0];
                                if(curr_supply_id==this_supply_id){
                                    var curr_array_temp = new Array(this_supply_id,curr_values);
                                    modify_Curr.push(curr_array_temp);
                                }else{
                                    modify_Curr.push(value);
                                }

                            });
                            _Curr = modify_Curr;//更新输入数组
                            var curr_array_json = JSON.stringify(_Curr);//转JSON
                            localStorage.setItem('curr_'+user_id,curr_array_json);
                        }
                    }
                    sum_all_money();
                }


			}else{													//当输入为空
				//console.log("222");
                //清空本地储存
                del_curr_product(this_supply_id);
                //清空输入框
				$('#user_currency_'+this_supply_id).val('');
				user_curr_money = get_user_curr_money();
				sum_all_money();

			}

             console.log(_Curr);
		});
        //console.log(user_curr_money);
        //console.log(_Curr);
	}


	//购物币监听
	function curr_listen(){

		var curr_object = localStorage.getItem('curr_'+user_id); 	//读取localStorage的数据

		var curr_object_arr = new Array();
        if(curr_object==null || curr_object==''){
            curr_object_arr = '';
        }else{
            curr_object_arr = JSON.parse(curr_object);						//json转数组
        }



		if(curr_object_arr ==null || curr_object_arr==''){

				envent_object_arr.event3 = '';									//清空事件3
				var event_arr_json = JSON.stringify(envent_object_arr);			//转JSON
				localStorage.setItem('envent_'+user_id,event_arr_json);			//初始化被动事件存入localStorage
		}else{
			$.each(curr_object_arr,function(i,value){
                if(value == null || value == ''){
                    return ;		//contiune的作用
                }
                var curr_supply_id   = value[0];
                //zhou
                var used_currency 	 = parseFloat(value[1])-parseFloat(sum_self_newreward) ;
                if(used_currency < 0)
	  			{
	  				used_currency = 0
	  			}

                if(used_currency == null || used_currency=='' ){
                    return ;		//contiune的作用
                }
                if(is_ban_currency[curr_supply_id] == 1 && is_ban_use_coupon_currency){

                	alertAutoClose('购物币和优惠券不能同时使用',2000);
                	return ;
                }

                is_curr[curr_supply_id] = 1;
                is_curr_count++;
                btn_on($('#open_curr_'+curr_supply_id));
                $('.currency_'+curr_supply_id).show();
                $('#user_currency_'+curr_supply_id).val(used_currency);

                user_curr_money = get_user_curr_money();
                if(is_check_password==0){
					/* 支付密码设置优化 create by hzq */
					<?php $_SESSION['pass_url_'.$customer_id] = '/weixinpl/mshop/order_form.php?customer_id='.$customer_id_en; ?>
					/* 支付密码设置优化 end */
                    check_has_password ();
                }
            });
		}


	}

	//购物币输入错误提示
	function curr_error(error_txt,supply_id){

			showAlertMsg("提示",error_txt,"知道了");						//提示内容

			$('#user_currency_'+supply_id).val('');									//清空输入框

			user_curr_money = get_user_curr_money();							//重新赋值为0

			sum_all_money();												//重新计算
			del_curr_product(supply_id)
			//localStorage.setItem('curr_'+user_id,'');						//清空购物币本地存储

            var sum_ov = 0;
            $.each($('.open_curr'),function(){
                var ov = $(this).attr('open_val');
                sum_ov += parseFloat(ov);
            });
            sum_ov = sum_ov - 1;//再减去当前事件
            if(sum_ov==0){
                //所有购物币开关都关了才清空事件3
                envent_object_arr.event3 = '';
            }else{
                envent_object_arr.event3 = 'curr';
            }
			//envent_object_arr.event3 = '';		//清空事件3


			var event_arr_json = JSON.stringify(envent_object_arr);			//转JSON

			localStorage.setItem('envent_'+user_id,event_arr_json);			//初始化被动事件存入localStorage

	}
    //获取本地储存中已填购物币金额总和
    function get_user_curr_money(){

        var user_curr_money    = 0;       //已填购物币数额

        //遍历购物币输入框
        $(".user_currency").each(function(){
            //获取标识
            //console.log(is_curr);
            var supply_id = $(this).attr('supply_id');
            //console.log(product_id);
            //有开启按钮才读取填入的购物币数量
            if(is_curr[supply_id]){
                //计算已输入购物币总和
                //console.log(product_id);
                this_currency = $(this).val();
                if(this_currency==null || this_currency==''){
                    this_currency = 0;
                }
                //console.log(this_currency);
                user_curr_money += parseFloat(this_currency);
                if(supply_id==-1){
                    platform_exchange_user_curr_money += parseFloat(this_currency);
                }
            }

        });

        return user_curr_money;
    }

    //删除数组中的一个本地储存，参数：删除的目标
    function del_curr_product(supply_id){
        //先读取现有本地储存
        var curr_object = localStorage.getItem('curr_'+user_id); 	//读取localStorage的数据
        var curr_object_arr = new Array();
        var del_Curr = new Array();
        if(curr_object==null || curr_object==''){
            curr_object_arr = '';
        }else{
            curr_object_arr = JSON.parse(curr_object);						//json转数组
        }
        if(curr_object_arr ==null || curr_object_arr==''){
            //本地存储为空
        }else{
            $.each(curr_object_arr,function(i,value){
            if(value == null || value == ''){
                return ;		//contiune的作用
            }
            var curr_supply_id 	= value[0];
            if(curr_supply_id!=supply_id){
            	//zhou
            	values = value+sum_self_newreward;
                del_Curr.push(value);
            }

            });
            _Curr = del_Curr;//更新输入数组
            var del_Curr_json = JSON.stringify(del_Curr);//转JSON

            localStorage.setItem('curr_'+user_id,del_Curr_json);

        }

    }

    //获取购物币本地储存数组
    function get_curr_local(){
        //读取本地储存
        var curr_object = localStorage.getItem('curr_'+user_id); 	//读取localStorage的数据
        var curr_object_arr = new Array();
        if(curr_object==null || curr_object==''){
            curr_object_arr = '';
        }else{
            curr_object_arr = JSON.parse(curr_object);						//json转数组
        }
        return curr_object_arr;

    }

	/******互斥事件3：使用购物币*******/


	/******互斥事件4：使用发票*******/
	//发票输入监听
	function invoice_input_listen(){

		$.each($('.itemWrapper'),function(i,value){

			var thiss = $(this);
			var supply_id = thiss.attr('supply_id');
			var ii = thiss.attr('ii');

			thiss.find('.invoice').bind('input propertychange', function() {

					var  invoice_values = $('.invoice').val();			//用户输入的发票抬头
					if(invoice_values!='' ){
						var rtn_array_temp = new Array(supply_id,invoice_values);
						envent_object_arr.event4 = 'invoice';
					}else{													//当输入为空

						envent_object_arr.event4 = '';									//清空事件4

					}

					var invoice_object = localStorage.getItem('invoice_'+user_id); 	//读取localStorage的数据
					var invoice_object_arr = new Array();
					invoice_object_arr = JSON.parse(invoice_object);				//json转数组

					if(invoice_object_arr==null || invoice_object_arr==''){			//创建
						var _A = new Array();
						_A[ii] = rtn_array_temp ;
						var rtn_array_json = JSON.stringify(_A);					//转JSON
						localStorage.setItem('invoice_'+user_id,rtn_array_json);	//存入localStorage

					}else{					 			//修改自己的内容
						invoice_object_arr[ii] = rtn_array_temp ;
						var rtn_array_json = JSON.stringify(invoice_object_arr);	//转JSON
						localStorage.setItem('invoice_'+user_id,rtn_array_json);	//存入localStorage

					}

					//设置事件4为invoice
					var event_arr_json = JSON.stringify(envent_object_arr);			//转JSON
					localStorage.setItem('envent_'+user_id,event_arr_json);			//初始化被动事件存入localStorage

				});
		});


	}

	//发票本地存储监听
	function invoice_listen(){

			var invoice_object = localStorage.getItem('invoice_'+user_id); 			//读取localStorage的数据
			var invoice_object_arr = new Array();
			invoice_object_arr = JSON.parse(invoice_object);						//json转数组
			if(invoice_object_arr ==null || invoice_object_arr==''){

			}else{

				$.each(invoice_object_arr,function(i,value){
					if(value == null || value == ''){
						return ;		//contiune的作用
					}
					var invoice_supply_id 	= value[0];
					var invoice 			= value[1];

					if(invoice == null || invoice==''){
						return ;		//contiune的作用
					}

					//遍历每个供应商的产品
					$.each($('#resultData .itemWrapper'),function(k,val){
						var thiss = $(this);

						var self_supply_id =  thiss.attr('supply_id');

						if(invoice_supply_id == self_supply_id){			//找到用户每个供应商对应选择的的发票

							thiss.find('.invoice').val(invoice);

						}

					});

				});
			}
	}

	/******互斥事件4：使用发票*******/


	/******互斥事件5：使用备注*******/

	//备注输入监听
	function remark_input_listen(){

		$.each($('.itemWrapper'),function(i,value){

			var thiss = $(this);
			var supply_id = thiss.attr('supply_id');
			var ii = thiss.attr('ii');

			thiss.find('.remark').bind('input propertychange', function() {

					var  remark_values = $('.remark').val();			//用户输入的发票抬头

					if(remark_values!='' ){

						var rtn_array_temp = new Array(supply_id,remark_values);

						envent_object_arr.event5 = 'remark';							//设置事件5为remark

					}else{																//当输入为空

						envent_object_arr.event5 = '';									//清空事件5

					}

					var remark_object = localStorage.getItem('remark_'+user_id); 	//读取localStorage的数据
					var remark_object_arr = new Array();
					remark_object_arr = JSON.parse(remark_object);			//json转数组

					if(remark_object_arr==null || remark_object_arr==''){		//创建本地存储
						var _A = new Array();
						_A[ii] = rtn_array_temp ;
						var rtn_array_json = JSON.stringify(_A);				//转JSON
						localStorage.setItem('remark_'+user_id,rtn_array_json);	//存入localStorage

					}else{					 									//修改自己的内容

						remark_object_arr[ii] = rtn_array_temp ;
						var rtn_array_json = JSON.stringify(remark_object_arr);	//转JSON
						localStorage.setItem('remark_'+user_id,rtn_array_json);	//存入localStorage

					}

					var event_arr_json = JSON.stringify(envent_object_arr);			//转JSON
					localStorage.setItem('envent_'+user_id,event_arr_json);			//初始化被动事件存入localStorage

				});
		});

	}

	//备注本地存储监听
	function remark_listen(){

			var remark_object = localStorage.getItem('remark_'+user_id); 			//读取localStorage的数据
			var invoice_object_arr = new Array();
			remark_object_arr = JSON.parse(remark_object);							//json转数组
			if(remark_object_arr ==null || remark_object_arr==''){

			}else{

				$.each(remark_object_arr,function(i,value){
					if(value == null || value == ''){
						return ;		//contiune的作用
					}
					var remark_supply_id 	= value[0];
					var remark 				= value[1];

					if(remark == null || remark==''){
						return ;		//contiune的作用
					}

					//遍历每个供应商的产品
					$.each($('#resultData .itemWrapper'),function(k,val){
						var thiss = $(this);

						var self_supply_id =  thiss.attr('supply_id');

						if(remark_supply_id == self_supply_id){			//找到用户每个供应商对应选择的的发票

							thiss.find('.remark').val(remark);

						}

					});

				});


			}
	}

	/******互斥事件5：使用备注*******/

	/************************互斥事件区域***********************/

	/************************跳转区域 start***********************/

	//跳转填写必填信息
	function go_to_info(obj){

		var PID_str = obj.attr('pid');
		var pros = obj.attr('pros');
		var supply_id = obj.attr('supply_id');
		var ii = obj.attr('ii');

		var strurl = "required-info.php?customer_id="+customer_id_en;
		//该供应商下的所有产品ID
		var post_data1 = new Array();
		post_data1['key'] = 'pid';
		post_data1['val'] = PID_str;
		//品牌供应商ID或者平台-1
		var post_data2 = new Array();
		post_data2['key'] = 'supply_id';
		post_data2['val'] = supply_id;
		//该供应商下的所有属性ID
		var post_data3 = new Array();
		post_data3['key'] = 'pros';
		post_data3['val'] = pros;
		//定位ID
		var post_data4 = new Array();
		post_data4['key'] = 'ii';
		post_data4['val'] = ii;

		var post_object = [];
		post_object.push(post_data1,post_data2,post_data3,post_data4);
		Turn_Post(post_object,strurl);

	}


    // post提交
    function post(url,value){
        var objform = document.createElement("form");
        // 循环参数
        url_arr = value.split('&');
        for (var i = 0; i < url_arr.length; i++) {
            value_arr = url_arr[i].split('=');
            var objInput = document.createElement("input");
            objInput.type = "hidden";
            objform.appendChild(objInput);
            objInput.value = value_arr[1];
            objInput.name = value_arr[0];
            // objInput = '';
        }
        objform.action = url;
        objform.target = "fraGrid"
        objform.method = "POST"
        document.body.appendChild(objform);
        objform.submit();
    }

	//跳转选择优惠券
	function go_select_coupon(){

		var sum_price = $('#sum_price').attr('sum_price');				//订单总价
        // sum_price = parseFloat(sum_price) - parseFloat('<?php echo $exchange; ?>');
		var post_data = new Array();
		post_data['key'] = 'n_p';
		post_data['val'] = sum_price;

		var strurl = "user_coupon.php?customer_id="+customer_id_en+'&w=1';
		var post_object = [];
		post_object.push(post_data);							//将产品金额传入post
		Turn_Post(post_object,strurl);									//POST提交到优惠券页面
	}

		//门店
	function go_to_store(obj){

		var supply_id = obj.attr('supply_id');
		var ii = obj.attr('ii');
		var address = "<?php echo $address_detail;?>";//address_detail;
		var strurl = "select_store.php?customer_id="+customer_id_en+"&address="+address;
		// window.location.href=strurl;
		// return;
		//品牌供应商ID或者平台-1
		var post_data1 = new Array();
		post_data1['key'] = 'supply_id';
		post_data1['val'] = supply_id;
		//定位ID
		var post_data2 = new Array();
		post_data2['key'] = 'ii';
		post_data2['val'] = ii;

		var post_data3 = new Array();
		post_data3['key'] = 'shop_card_id';
		post_data3['val'] = shop_card_id;

		var post_data4 = new Array();
		post_data4['key'] = 'pid';
		post_data4['val'] = pid;

		var post_object = [];
		post_object.push(post_data1,post_data2,post_data3,post_data4);
		Turn_Post(post_object,strurl);

	}
    //订货系统门店
    function go_to_orderingretail_store (obj)
    {
        obj = $(obj);
        var supply_id = obj.attr('supply_id');
		var ii = obj.attr('ii');
		var supply_pid_str = obj.attr('supply_pid_str');
		var supply_pros_str = obj.attr('supply_pros_str');
		var pidcount_str = obj.attr('pidcount_str');
        var address = '<?php echo $address_detail;?>';// address_detail;
        var city = '<?php echo $location_c; ?>';
        var shop_id = '<?php echo $o_shop_id; ?>';
		var strurl = "select_shop.php?customer_id="+customer_id_en+"&address="+address+'&city='+city;

		//品牌供应商ID或者平台-1
		var post_data1 = new Array();
		post_data1['key'] = 'supply_id';
		post_data1['val'] = supply_id;
		//定位ID
		var post_data2 = new Array();
		post_data2['key'] = 'ii';
		post_data2['val'] = ii;
        //产品id字符串
		var post_data3 = new Array();
		post_data3['key'] = 'supply_pid_str';
		post_data3['val'] = supply_pid_str;
        //产品属性字符串
		var post_data4 = new Array();
		post_data4['key'] = 'supply_pros_str';
		post_data4['val'] = supply_pros_str;
		//商品数量
		var post_data5 = new Array();
		post_data5['key'] = 'pidcount_str';
		post_data5['val'] = pidcount_str;
		 console.log(supply_pros_str);
        //订货系统门店id
        if(shop_id>-1){
            var post_data6 = new Array();
            post_data6['key'] = 'shop_id';
            post_data6['val'] = shop_id;
        }
		var post_object = [];
		post_object.push(post_data1,post_data2,post_data3,post_data4,post_data5);
		Turn_Post(post_object,strurl);
    }

	//选择配送方式
	function choose_send_way(obj){
		var supply_id = $(obj).attr('supply_id');
		var ii = $(obj).attr('ii');
        var supply_express = $(obj).attr('supply_express');
        var sum_express = $(obj).attr('sum_express');
        var supply_pid_str = $(obj).attr('supply_pid_str');
        var supply_pros_str = $(obj).attr('supply_pros_str');
        var pidcount_str = $(obj).attr('pidcount_str');
        var city = '<?php echo $location_c?>';

        if (supply_express == 'failed')
        {
            sum_express = -1;
        }

		var strurl = "choose_send_way.php?customer_id="+customer_id_en;
		//品牌供应商ID或者平台-1
		var post_data1 = new Array();
		post_data1['key'] = 'supply_id';
		post_data1['val'] = supply_id;
		//定位ID
		var post_data2 = new Array();
		post_data2['key'] = 'ii';
		post_data2['val'] = ii;

        var post_data3 = new Array();
		post_data3['key'] = 'sum_express';
		post_data3['val'] = sum_express;

        var post_data4 = new Array();
		post_data4['key'] = 'supply_pid_str';
		post_data4['val'] = supply_pid_str;

        var post_data5 = new Array();
		post_data5['key'] = 'supply_pros_str';
		post_data5['val'] = supply_pros_str;

		var post_data6 = new Array();
		post_data6['key'] = 'pidcount_str';
		post_data6['val'] = pidcount_str;

		var post_data7 = new Array();
		post_data7['key'] = 'city';
		post_data7['val'] = city;

		var post_object = [];
		post_object.push(post_data1,post_data2,post_data3,post_data4,post_data5,post_data6,post_data7);
		Turn_Post(post_object,strurl);
	}

	//优惠券
	function go_to_coupon(obj){

		var supply_id = obj.attr('supply_id');
		var ii = obj.attr('ii');
		var p_id = '';//当前的产品id
		var p_price = 0;//当前的产品总价格
		var p_price = 0;//当前的产品总价格
		//遍历当前店铺的产品和产品总价格
		obj.parent().parent().find('.product').each(function(){
			var pid = $(this).attr('pid');
			p_id += p_id==''?pid:","+pid;

			var p_proPrice = $(this).find('.itemProPrice').text();
			var p_proCount = $(this).find('.itemProCount').text();
			p_proPrice = p_proPrice.replace(/(^\s*)|(\s*$)/g, "");
			p_proPrice = p_proPrice.substr(1);
			p_proPrice = p_proPrice.replace(/(^\s*)|(\s*$)/g, "")

			var pprice = p_proPrice*p_proCount.substr(1,p_proCount.length-1);
            p_price += p_price==''?pprice:","+pprice;
		});
		var current_sum_price = obj.parent().find('.sum_price_supply').val();				//当前订单总价
        // 满增换购活动
        exchange_price_ex = '<?php echo $total_exchange_price ?>';
        if (exchange_price_ex != '') {
        	current_sum_price = parseFloat(current_sum_price) - parseFloat('<?php echo $total_exchange_price ?>');
        }

		var strurl = "user_coupon.php?customer_id="+customer_id_en+"&w=1";
		//品牌供应商ID或者平台-1
		var post_data1 = new Array();
		post_data1['key'] = 'supply_id';
		post_data1['val'] = supply_id;
		//定位ID
		var post_data2 = new Array();
		post_data2['key'] = 'ii';
		post_data2['val'] = ii;

		var post_data3 = new Array();
		post_data3['key'] = 'pid';
		post_data3['val'] = p_id;

		var post_data4 = new Array();
		post_data4['key'] = 'pprice';
		post_data4['val'] = p_price;

		var post_data5 = new Array();
		post_data5['key'] = 'n_p';
		post_data5['val'] = current_sum_price;

		var post_data6 = new Array();
		post_data6['key'] = 'is_use_free_coupon';
		post_data6['val'] = is_use_free_coupon;
        
        var post_data7 = new Array();
		post_data7['key'] = 'coupon_onoff';
		post_data7['val'] = coupon_onoff;
        
        console.log(post_data1,post_data2,post_data3,post_data4,post_data5,post_data6,post_data7)

		var post_object = [];
		post_object.push(post_data1,post_data2,post_data3,post_data4,post_data5,post_data6,post_data7);
		Turn_Post(post_object,strurl);

	}

		//自定义区域
	function go_to_diy_area(obj){

		var supply_id = obj.attr('supply_id');
		var ii = obj.attr('ii');

		var strurl = "select_diy_area.php?customer_id="+customer_id_en;

		var post_data1 = new Array();
		post_data1['key'] = 'all_areaname';
		post_data1['val'] = '<?php echo $location_p.$location_c.$location_a?>';

		var post_object = [];
		post_object.push(post_data1);
		Turn_Post(post_object,strurl);

	}
	/************************跳转区域 end***********************/


/*POST提交数据*/
function Turn_Post(object,strurl){
  //object:需要创建post数据一对数组 [key:val]

	/* 将GET方法改为POST ----start---*/

    var objform = document.createElement('form');
	document.body.appendChild(objform);


	$.each(object,function(i,value){

		var obj_p = document.createElement("input");
		obj_p.type = "hidden";
		objform.appendChild(obj_p);
		obj_p.value = value['val'];
		obj_p.name = value['key'];
	});

	objform.action = strurl;
	objform.method = "POST"
	objform.submit();
	/* 将GET方法改为POST ----end---*/
}
/*POST提交数据*/

function clearNoNum(obj){
	obj.value = obj.value.replace(/[^\d.]/g,""); //清除"数字"和"."以外的字符
	obj.value = obj.value.replace(/^\./g,""); //验证第一个字符是数字而不是
	obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的
	obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
	obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3'); //只能输入两个小数
}

    // $(".sharebg").click(function() {
    //         $('#ipt').val("");
    //         $('li').text("");
    //         $("#pass_w").hide();
    //         $(".sharebg").hide();
    //         //$("box").hide();
    //     });
    $('#ipt').on('input', function (e){
        //alert(11);
        var numLen = 6;
        var pw = $('#ipt').val();
        //alert(pw);
        var list = $('li');
        for(var i=0; i<numLen; i++){
            //alert(pw[i]);
             if(pw[i]){
                //alert(pw[i]);
                $(list[i]).text('·');
            }else{
                $(list[i]).text('');
            }
        }
    });

    function xiugai_pass(){
        window.location.href="change_paypassword.php?customer_id=<?php echo $customer_id_en;?>";
     }
    $(".opacity_sharebg").click(function () {
     	$(".opacity_sharebg").hide();//遮罩层出现调用
        //$(".opacity_sharebg").css('opacity',0);
        $("#pass_w").hide();
    });

// $(".chakanmoveth").click(function () {
// 	$(this).hide();
// 	$("#new_zhifuPannel").addClass("scrolly");
// });
	/********************函数部分*********************/
    // 满赠换购专区
    function exchange(){
        $('#exchange_price').val(platform_final_price)
        $('#excahnge_form').submit();
    }
    // 积分类型

    $(".choose_integral_type").click(function () {

   		$("#gyuji").show();
   		$(".jifen-type-alert").show();
   		$(".jifen-content").click(function () {
   			$(this).find(".select-box").addClass("add-gou");
   			$(this).siblings(".jifen-content").find(".select-box").removeClass("add-gou");
   		});
    })
   	$("#jifen-cancle-btn").click(function () {
   		$("#gyuji").hide();
   		$(".jifen-type-alert").hide();
   	})
   	$("#jifen-sure-btn").click(function () {
   		$('.jifen-type-alert').find('.select-box').each(function(index){
   			if($(this).hasClass('add-gou')){
   				var type=$(this).attr('val');
   				var type_ind=$(this).attr('ind');
   				$('.choose_store_integral').css('display','none');
   				$('.choose_shop_integral').css('display','none');
   				$('.choose_'+type+'_integral').css('display','');
   				using_exchange_type = type_ind;		//改变兑换类型
   				setCookie("using_exchange_type_"+user_id,type_ind,1);

   			}
   		});
   		$("#gyuji").hide();
   		$(".jifen-type-alert").hide();

   	})

    $('#user_currency_-1').trigger('input')
</script>


<form action="/mshop/admin/index.php?m=exchange&a=full_give&customer_id=<?php echo $customer_id_en ?>" id='excahnge_form'  method="post" accept-charset="utf-8" >
    <input type="hidden" name="price" id='exchange_price'>
</form>


<!--<script src="./js/goods/order_form.js?v=--><?php //echo time();?><!--"></script>-->
<script src="./js/goods/new_order_form.js?ver=2<?php echo time()?>"></script>
<?php require('../common/share.php');?>
</body>
</html>
